Struct soroban_env_host::xdr::DepthLimitedRead
pub struct DepthLimitedRead<R>where
R: Read,{
pub inner: R,
/* private fields */
}Expand description
DepthLimitedRead wraps a Read object and enforces a depth limit to
recursive read operations. It maintains a depth_remaining state tracking
remaining allowed recursion depth.
Fields§
§inner: RImplementations§
§impl<R> DepthLimitedRead<R>where
R: Read,
impl<R> DepthLimitedRead<R>where R: Read,
pub fn new(inner: R, depth_limit: u32) -> DepthLimitedRead<R> ⓘ
pub fn new(inner: R, depth_limit: u32) -> DepthLimitedRead<R> ⓘ
Constructs a new DepthLimitedRead.
inner: The object implementing theReadtrait.depth_limit: The maximum allowed recursion depth.
Trait Implementations§
§impl<R> DepthLimiter for DepthLimitedRead<R>where
R: Read,
impl<R> DepthLimiter for DepthLimitedRead<R>where R: Read,
§fn enter(&mut self) -> Result<(), Error>
fn enter(&mut self) -> Result<(), Error>
Decrements the depth_remaining. If the depth_remaining 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<R> Read for DepthLimitedRead<R>where
R: Read,
impl<R> Read for DepthLimitedRead<R>where R: Read,
§fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
fn read(&mut self, buf: &mut [u8]) -> Result<usize, Error>
Forwards the read operation to the wrapped object.
1.36.0 · source§fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
fn read_vectored(&mut self, bufs: &mut [IoSliceMut<'_>]) -> Result<usize, Error>
Like
read, except that it reads into a slice of buffers. Read moresource§fn is_read_vectored(&self) -> bool
fn is_read_vectored(&self) -> bool
🔬This is a nightly-only experimental API. (
can_vector)1.0.0 · source§fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
fn read_to_end(&mut self, buf: &mut Vec<u8, Global>) -> Result<usize, Error>
Read all bytes until EOF in this source, placing them into
buf. Read more1.0.0 · source§fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
fn read_to_string(&mut self, buf: &mut String) -> Result<usize, Error>
Read all bytes until EOF in this source, appending them to
buf. Read more1.6.0 · source§fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
fn read_exact(&mut self, buf: &mut [u8]) -> Result<(), Error>
Read the exact number of bytes required to fill
buf. Read moresource§fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf(&mut self, buf: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Pull some bytes from this source into the specified buffer. Read more
source§fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
fn read_buf_exact(&mut self, cursor: BorrowedCursor<'_>) -> Result<(), Error>
🔬This is a nightly-only experimental API. (
read_buf)Read the exact number of bytes required to fill
cursor. Read more1.0.0 · source§fn by_ref(&mut self) -> &mut Selfwhere
Self: Sized,
fn by_ref(&mut self) -> &mut Selfwhere Self: Sized,
Creates a “by reference” adaptor for this instance of
Read. Read moreAuto Trait Implementations§
impl<R> RefUnwindSafe for DepthLimitedRead<R>where R: RefUnwindSafe,
impl<R> Send for DepthLimitedRead<R>where R: Send,
impl<R> Sync for DepthLimitedRead<R>where R: Sync,
impl<R> Unpin for DepthLimitedRead<R>where R: Unpin,
impl<R> UnwindSafe for DepthLimitedRead<R>where R: 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
source§impl<T, U, E, C> Compare<(T, U)> for Cwhere
C: Compare<T, Error = E, Error = E> + Compare<U>,
impl<T, U, E, C> Compare<(T, U)> for Cwhere C: Compare<T, Error = E, Error = E> + Compare<U>,
source§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>,
source§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>
source§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.