Struct soroban_sdk::xdr::DepthLimitedWrite
pub struct DepthLimitedWrite<W>where
W: Write,{
pub inner: W,
/* private fields */
}
Expand description
DepthLimitedWrite
wraps a Write
object and enforces a depth limit to
recursive write operations. It maintains a depth_remaining
state tracking
remaining allowed recursion depth.
Fields§
§inner: W
Implementations§
§impl<W> DepthLimitedWrite<W>where
W: Write,
impl<W> DepthLimitedWrite<W>where W: Write,
pub fn new(inner: W, depth_limit: u32) -> DepthLimitedWrite<W> ⓘ
pub fn new(inner: W, depth_limit: u32) -> DepthLimitedWrite<W> ⓘ
Constructs a new DepthLimitedWrite
.
inner
: The object implementing theWrite
trait.depth_limit
: The maximum allowed recursion depth.
Trait Implementations§
§impl<W> DepthLimiter for DepthLimitedWrite<W>where
W: Write,
impl<W> DepthLimiter for DepthLimitedWrite<W>where W: Write,
§fn enter(&mut self) -> Result<(), Error>
fn enter(&mut self) -> Result<(), Error>
Decrements the depth_remaining
. If the depth is already zero, an error is
returned indicating that the maximum depth limit has been exceeded.
§fn leave(&mut self) -> Result<(), Error>
fn leave(&mut self) -> Result<(), Error>
Increments the depth. leave
should be called in tandem with enter
such that the depth
doesn’t exceed the initial depth limit.
§type DepthLimiterError = Error
type DepthLimiterError = Error
A general error type for any type implementing, or an operation under the guard of
DepthLimiter
. It must at least include the error case where the depth limit is exceeded
which is returned from enter
.§fn with_limited_depth<T, F>(
&mut self,
f: F
) -> Result<T, Self::DepthLimiterError>where
F: FnOnce(&mut Self) -> Result<T, Self::DepthLimiterError>,
fn with_limited_depth<T, F>( &mut self, f: F ) -> Result<T, Self::DepthLimiterError>where F: FnOnce(&mut Self) -> Result<T, Self::DepthLimiterError>,
Wraps a given function
f
with depth limiting guards.
It triggers an enter
before, and a leave
after the execution of f
. Read more§impl<W> Write for DepthLimitedWrite<W>where
W: Write,
impl<W> Write for DepthLimitedWrite<W>where W: Write,
§fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
fn write(&mut self, buf: &[u8]) -> Result<usize, Error>
Forwards the write operation to the wrapped object.
source§fn is_write_vectored(&self) -> bool
fn is_write_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector
)1.0.0 · source§fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
fn write_all(&mut self, buf: &[u8]) -> Result<(), Error>
Attempts to write an entire buffer into this writer. Read more
source§fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
fn write_all_vectored(&mut self, bufs: &mut [IoSlice<'_>]) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
write_all_vectored
)Attempts to write multiple buffers into this writer. Read more
Auto Trait Implementations§
impl<W> RefUnwindSafe for DepthLimitedWrite<W>where W: RefUnwindSafe,
impl<W> Send for DepthLimitedWrite<W>where W: Send,
impl<W> Sync for DepthLimitedWrite<W>where W: Sync,
impl<W> Unpin for DepthLimitedWrite<W>where W: Unpin,
impl<W> UnwindSafe for DepthLimitedWrite<W>where W: UnwindSafe,
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
§impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
impl<T, U, V, E, C> Compare<(T, U, V)> for Cwhere C: Compare<T, Error = E, Error = E, Error = E> + Compare<U> + Compare<V>,
§impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,
impl<T, U, V, W, E, C> Compare<(T, U, V, W)> for Cwhere C: Compare<T, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W>,
type Error = E
fn compare( &self, a: &(T, U, V, W), b: &(T, U, V, W) ) -> Result<Ordering, <C as Compare<(T, U, V, W)>>::Error>
§impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for Cwhere
C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,
impl<T, U, V, W, X, E, C> Compare<(T, U, V, W, X)> for Cwhere C: Compare<T, Error = E, Error = E, Error = E, Error = E, Error = E> + Compare<U> + Compare<V> + Compare<W> + Compare<X>,
type Error = E
fn compare( &self, a: &(T, U, V, W, X), b: &(T, U, V, W, X) ) -> Result<Ordering, <C as Compare<(T, U, V, W, X)>>::Error>
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
fn into_any(self: Box<T, Global>) -> Box<dyn Any, Global>
Convert
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
fn into_any_rc(self: Rc<T, Global>) -> Rc<dyn Any, Global>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.