diff --git a/libs/deer/desert/src/array.rs b/libs/deer/desert/src/array.rs index 15b992359cc..23deb297846 100644 --- a/libs/deer/desert/src/array.rs +++ b/libs/deer/desert/src/array.rs @@ -3,7 +3,7 @@ use deer::{ ArrayAccessError, ArrayLengthError, BoundedContractViolationError, ExpectedLength, ReceivedLength, Variant, }, - Deserialize, Deserializer as _, + Context, Deserialize, Deserializer as _, }; use error_stack::{Report, Result, ResultExt}; @@ -57,6 +57,10 @@ impl<'a, 'b, 'de> ArrayAccess<'a, 'b, 'de> { } impl<'de> deer::ArrayAccess<'de> for ArrayAccess<'_, '_, 'de> { + fn context(&self) -> &Context { + self.deserializer.context() + } + fn set_bounded(&mut self, length: usize) -> Result<(), ArrayAccessError> { if self.consumed > 0 { return Err( diff --git a/libs/deer/desert/src/object.rs b/libs/deer/desert/src/object.rs index f0b69ae5976..dea443e2cec 100644 --- a/libs/deer/desert/src/object.rs +++ b/libs/deer/desert/src/object.rs @@ -3,7 +3,7 @@ use deer::{ BoundedContractViolationError, ExpectedLength, ObjectAccessError, ObjectLengthError, ReceivedLength, Variant, }, - Deserializer as _, FieldVisitor, + Context, Deserializer as _, FieldVisitor, }; use error_stack::{Report, Result, ResultExt}; @@ -57,6 +57,10 @@ impl<'a, 'b, 'de: 'a> ObjectAccess<'a, 'b, 'de> { } impl<'de> deer::ObjectAccess<'de> for ObjectAccess<'_, '_, 'de> { + fn context(&self) -> &Context { + self.deserializer.context() + } + fn set_bounded(&mut self, length: usize) -> Result<(), ObjectAccessError> { if self.consumed > 0 { return Err( diff --git a/libs/deer/json/src/lib.rs b/libs/deer/json/src/lib.rs index 978215f033a..8a0d089a93b 100644 --- a/libs/deer/json/src/lib.rs +++ b/libs/deer/json/src/lib.rs @@ -455,6 +455,10 @@ impl<'a> ArrayAccess<'a> { } impl<'a, 'de> deer::ArrayAccess<'de> for ArrayAccess<'a> { + fn context(&self) -> &Context { + self.context + } + fn set_bounded(&mut self, length: usize) -> Result<(), ArrayAccessError> { if self.dirty { return Err( @@ -550,6 +554,10 @@ impl<'a> ObjectAccess<'a> { } impl<'a, 'de> deer::ObjectAccess<'de> for ObjectAccess<'a> { + fn context(&self) -> &Context { + self.context + } + fn set_bounded(&mut self, length: usize) -> Result<(), ObjectAccessError> { if self.dirty { return Err( diff --git a/libs/deer/src/lib.rs b/libs/deer/src/lib.rs index 7f6d1745d9a..b0cf0e3acda 100644 --- a/libs/deer/src/lib.rs +++ b/libs/deer/src/lib.rs @@ -66,6 +66,8 @@ type FieldValue<'de, F> = >::Value; type FieldResult<'de, F> = Option, ObjectAccessError>>; pub trait ObjectAccess<'de> { + fn context(&self) -> &Context; + /// This enables bound-checking for [`ObjectAccess`]. /// /// After calling this [`ObjectAccess`] will @@ -115,6 +117,8 @@ pub trait FieldVisitor<'de> { } pub trait ArrayAccess<'de> { + fn context(&self) -> &Context; + /// Enables bound-checking for [`ArrayAccess`]. /// /// After calling this [`ArrayAccess`] will