InlineableAtomic::a_ideserialize
This commit is contained in:
parent
a05dcb7ff8
commit
5baf4bf4ad
@ -50,6 +50,12 @@ impl InlineableAtomic for u64 {
|
|||||||
fn a_extension_error(tail: &[u8]) -> Self::AParseError {
|
fn a_extension_error(tail: &[u8]) -> Self::AParseError {
|
||||||
IntParseError::ExtraData(tail.len())
|
IntParseError::ExtraData(tail.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn a_ideserialize<D: InlineableDeserializer>(deserializer: D) -> ADParseResult<Self, D> {
|
||||||
|
let (x, deserializer) =
|
||||||
|
deserializer.iread_n_const::<8>(|slice| IntParseError::from(slice))?;
|
||||||
|
Ok((u64::from_le_bytes(x), deserializer))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstSizeAtomic for u64 {
|
impl ConstSizeAtomic for u64 {
|
||||||
|
@ -62,6 +62,16 @@ impl InlineableAtomic for bool {
|
|||||||
fn a_extension_error(tail: &[u8]) -> Self::AParseError {
|
fn a_extension_error(tail: &[u8]) -> Self::AParseError {
|
||||||
BooleanParseError::ExtraData(tail.len())
|
BooleanParseError::ExtraData(tail.len())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn a_ideserialize<D: InlineableDeserializer>(deserializer: D) -> ADParseResult<Self, D> {
|
||||||
|
let (byte, deserializer) =
|
||||||
|
deserializer.iread_n_const::<1>(|slice| BooleanParseError::from(slice))?;
|
||||||
|
match byte[0] {
|
||||||
|
0 => Ok((false, deserializer)),
|
||||||
|
1 => Ok((true, deserializer)),
|
||||||
|
value => Err(BooleanParseError::OutOfBounds(value)),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ConstSizeAtomic for bool {
|
impl ConstSizeAtomic for bool {
|
||||||
|
@ -117,6 +117,8 @@ pub type ADParseResult<A, D> = Result<(A, D), <A as Atomic>::AParseError>;
|
|||||||
/// Atomic analogue of [`InlineableFactory`]/[`InlineableObject`].
|
/// Atomic analogue of [`InlineableFactory`]/[`InlineableObject`].
|
||||||
pub trait InlineableAtomic: Atomic {
|
pub trait InlineableAtomic: Atomic {
|
||||||
fn a_extension_error(tail: &[u8]) -> Self::AParseError;
|
fn a_extension_error(tail: &[u8]) -> Self::AParseError;
|
||||||
|
|
||||||
|
fn a_ideserialize<D: InlineableDeserializer>(deserializer: D) -> ADParseResult<Self, D>;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Atomic analogue of [`ConstSizeFactory`]/[`ConstSizeObject`].
|
/// Atomic analogue of [`ConstSizeFactory`]/[`ConstSizeObject`].
|
||||||
|
Loading…
Reference in New Issue
Block a user