ResultDyn

This commit is contained in:
AF 2023-06-30 21:51:39 +00:00
parent 6a4cb9504c
commit c016fa44e6

View File

@ -88,8 +88,10 @@ impl<'a: 'c, 'c, Ctx: Context<'a>> InCtx<'a, Ctx> for &'c mut dyn DeCtx<'a, Ctx>
}
}
pub type ResultDyn<A, I> = Result<(A, I), Vec<u8>>;
pub trait InliningDyn<'c>: 'c {
fn idread_n(self, n: usize) -> Result<(Vec<u8>, Box<dyn InliningDyn<'c>>), Vec<u8>>;
fn idread_n(self, n: usize) -> ResultDyn<Vec<u8>, Box<dyn InliningDyn<'c>>>;
fn idread_all(self) -> Vec<u8>;
@ -97,7 +99,7 @@ pub trait InliningDyn<'c>: 'c {
}
impl<'c, I: 'c + Inlining> InliningDyn<'c> for I {
fn idread_n(self, n: usize) -> Result<(Vec<u8>, Box<dyn InliningDyn<'c>>), Vec<u8>> {
fn idread_n(self, n: usize) -> ResultDyn<Vec<u8>, Box<dyn InliningDyn<'c>>> {
let (vec, i) = self.iread_n(n, |slice| Vec::from(slice), |slice| Vec::from(slice))?;
Ok((vec, Box::new(i)))
}
@ -112,13 +114,13 @@ impl<'c, I: 'c + Inlining> InliningDyn<'c> for I {
}
pub trait InCtxDyn<'a: 'c, 'c, Ctx: Context<'a>>: InliningDyn<'c> {
fn icdnext_address(self) -> Result<(Address, Box<dyn InCtxDyn<'a, 'c, Ctx>>), Vec<u8>>;
fn icdnext_address(self) -> ResultDyn<Address, Box<dyn InCtxDyn<'a, 'c, Ctx>>>;
fn idresolver(&self) -> Rc<dyn Resolver<'a, Ctx>>;
}
impl<'a: 'c, 'c, Ctx: Context<'a>, I: 'c + InCtx<'a, Ctx>> InCtxDyn<'a, 'c, Ctx> for I {
fn icdnext_address(self) -> Result<(Address, Box<dyn InCtxDyn<'a, 'c, Ctx>>), Vec<u8>> {
fn icdnext_address(self) -> ResultDyn<Address, Box<dyn InCtxDyn<'a, 'c, Ctx>>> {
let (address, i) = self.icnext_address(|slice| Vec::from(slice))?;
Ok((address, Box::new(i)))
}