InCtx::icnext_*
This commit is contained in:
parent
c981eee116
commit
a5a4cadef6
@ -34,7 +34,15 @@ impl<D: ?Sized + Deserializer> Inlining for &mut D {
|
||||
}
|
||||
}
|
||||
|
||||
pub trait InCtx<'a, Ctx: Context<'a>>: Inlining {}
|
||||
pub trait InCtx<'a, Ctx: Context<'a>>: Inlining {
|
||||
fn icnext_address<E>(self, err: impl FnOnce(&[u8]) -> E) -> Result<(Address, Self), E>;
|
||||
|
||||
fn icnext_point<'b, A: Mentionable<'a, Ctx>, E>(
|
||||
self,
|
||||
factory: A::Fctr,
|
||||
err: impl FnOnce(&[u8]) -> E,
|
||||
) -> Result<(Point<'a, Ctx, A>, Self), E>;
|
||||
}
|
||||
|
||||
struct InCtxT<'a: 'c, 'c, Ctx: Context<'a>> {
|
||||
dectx: &'c mut dyn DeCtx<'a, Ctx>,
|
||||
@ -62,7 +70,27 @@ impl<'a: 'c, 'c, Ctx: Context<'a>> Inlining for InCtxT<'a, 'c, Ctx> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for InCtxT<'a, 'c, Ctx> {}
|
||||
impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for InCtxT<'a, 'c, Ctx> {
|
||||
fn icnext_address<E>(self, err: impl FnOnce(&[u8]) -> E) -> Result<(Address, Self), E> {
|
||||
let (addresses, deserialiser, _) = self.dectx.adr();
|
||||
match deserialiser.inext_address(addresses, err) {
|
||||
Ok((address, _)) => Ok((address, self)),
|
||||
Err(e) => Err(e),
|
||||
}
|
||||
}
|
||||
|
||||
fn icnext_point<'b, A: Mentionable<'a, Ctx>, E>(
|
||||
self,
|
||||
factory: A::Fctr,
|
||||
err: impl FnOnce(&[u8]) -> E,
|
||||
) -> Result<(Point<'a, Ctx, A>, Self), E> {
|
||||
let (point, inctx) = self.icnext_address(err)?;
|
||||
Ok((
|
||||
Point::from_address(point, factory, inctx.dectx.resolver()),
|
||||
inctx,
|
||||
))
|
||||
}
|
||||
}
|
||||
|
||||
pub type IParseResult<'a, Ctx, F, I> =
|
||||
Result<(Mtbl<'a, Ctx, F>, I), <F as Factory<'a, Ctx>>::ParseError>;
|
||||
|
Loading…
Reference in New Issue
Block a user