-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support BOOLEAN asn types and rename asn-attribute optional to option #…
- Loading branch information
1 parent
545fd57
commit 5d79ac9
Showing
7 changed files
with
111 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::syn::{ReadableType, Reader, WritableType, Writer}; | ||
use core::marker::PhantomData; | ||
|
||
pub struct Boolean<C: Constraint = NoConstraint>(PhantomData<C>); | ||
|
||
impl<C: Constraint> Default for Boolean<C> { | ||
fn default() -> Self { | ||
Boolean(Default::default()) | ||
} | ||
} | ||
|
||
pub trait Constraint {} | ||
|
||
#[derive(Default)] | ||
pub struct NoConstraint; | ||
impl Constraint for NoConstraint {} | ||
|
||
impl<C: Constraint> WritableType for Boolean<C> { | ||
type Type = bool; | ||
|
||
fn write_value<W: Writer>( | ||
writer: &mut W, | ||
value: &Self::Type, | ||
) -> Result<(), <W as Writer>::Error> { | ||
writer.write_boolean::<C>(*value) | ||
} | ||
} | ||
|
||
impl<C: Constraint> ReadableType for Boolean<C> { | ||
type Type = bool; | ||
|
||
fn read_value<R: Reader>(reader: &mut R) -> Result<Self::Type, <R as Reader>::Error> { | ||
reader.read_boolean::<C>() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters