AtomicExt::o_deserialise
This commit is contained in:
parent
d3d36d973d
commit
805809a7ba
@ -36,11 +36,17 @@ fn _parse_slice<A: Atomic>(slice: &[u8]) -> Result<A, A::AParseError> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Extension trait to provide method-like utilities associated with [Atomic]s.
|
/// Extension trait to provide method-like utilities associated with [Atomic]s.
|
||||||
pub trait ExtAtomic: Atomic {
|
pub trait AtomicExt: Atomic {
|
||||||
/// Static equivalent of [`FactoryExt::parse_slice`].
|
/// Static equivalent of [`FactoryExt::parse_slice`].
|
||||||
fn parse_slice(slice: &[u8]) -> Result<Self, Self::AParseError> {
|
fn parse_slice(slice: &[u8]) -> Result<Self, Self::AParseError> {
|
||||||
_parse_slice(slice)
|
_parse_slice(slice)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn o_deserialise<'a, Ctx: Context<'a>>(
|
||||||
|
dectx: &mut dyn DeCtx<'a, Ctx>,
|
||||||
|
) -> Result<Self, Self::AParseError> {
|
||||||
|
Self::a_deserialize(dectx.deserializer())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<A: Atomic> ExtAtomic for A {}
|
impl<A: Atomic> AtomicExt for A {}
|
||||||
|
@ -73,7 +73,7 @@ impl<'a, Ctx: Context<'a>, A: Atomic> Factory<'a, Ctx> for AtomicFactory<A> {
|
|||||||
type ParseError = A::AParseError;
|
type ParseError = A::AParseError;
|
||||||
|
|
||||||
fn deserialize(&self, dectx: &mut dyn DeCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
fn deserialize(&self, dectx: &mut dyn DeCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||||
Ok(A::a_deserialize(dectx.deserializer())?.into())
|
Ok(A::o_deserialise(dectx)?.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn extend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
fn extend(&self, mentionable: Self::Mtbl, tail: &[u8]) -> ParseResult<'a, Ctx, Self> {
|
||||||
|
@ -159,7 +159,7 @@ impl<'a, Ctx: Context<'a>, F: Factory<'a, Ctx>> Factory<'a, Ctx> for TreeFactory
|
|||||||
|
|
||||||
fn deserialize(&self, dectx: &mut dyn DeCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
fn deserialize(&self, dectx: &mut dyn DeCtx<'a, Ctx>) -> ParseResult<'a, Ctx, Self> {
|
||||||
let node = self.0.deserialize(dectx)?;
|
let node = self.0.deserialize(dectx)?;
|
||||||
let height = u64::a_deserialize(dectx.deserializer())?;
|
let height = u64::o_deserialise(dectx)?;
|
||||||
let tree = Tree { node, height };
|
let tree = Tree { node, height };
|
||||||
tree.validate_height()?;
|
tree.validate_height()?;
|
||||||
Ok(tree)
|
Ok(tree)
|
||||||
|
Loading…
Reference in New Issue
Block a user