pub struct Ctx<'a> {
pub resolver: &'a dyn ResolverTrait,
/* private fields */
}Expand description
Some context that’s maintained when reading and writing packets.
For packets that involve registries, you are required to pass a
RegistryHolder, otherwise reading and writing them will fail. For other
packets, it’s OK to pass Ctx::default().
Fields§
§resolver: &'a dyn ResolverTraitImplementations§
Source§impl<'a> Ctx<'a>
impl<'a> Ctx<'a>
pub fn new(resolver: &'a dyn ResolverTrait) -> Self
Sourcepub fn inc_depth(self) -> Result<Self, BufReadError>
pub fn inc_depth(self) -> Result<Self, BufReadError>
Increment the depth counter, or error if it exceeds the limit.
This exists to prevent exploits that make us crash by exhausting our
stack space. The AzBuf macro adds this whenever Ctx is used,
though if you know that recursion isn’t possible with a type then it’s
not strictly necessary.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for Ctx<'a>
impl<'a> !UnwindSafe for Ctx<'a>
impl<'a> Forget for Ctx<'a>
impl<'a> Freeze for Ctx<'a>where
&'a (dyn ResolverTrait + 'static): Freeze,
impl<'a> Move for Ctx<'a>
impl<'a> Send for Ctx<'a>where
&'a (dyn ResolverTrait + 'static): Send,
impl<'a> Sync for Ctx<'a>
impl<'a> Unpin for Ctx<'a>where
&'a (dyn ResolverTrait + 'static): Unpin,
impl<'a> UnsafeUnpin for Ctx<'a>where
&'a (dyn ResolverTrait + 'static): UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more