Struct salvo_core::Depot
source · [−]pub struct Depot { /* private fields */ }
Expand description
Depot if for store temp data of current request. Each handler can read or write data to it.
Implementations
sourceimpl Depot
impl Depot
sourcepub fn new() -> Depot
pub fn new() -> Depot
Creates an empty Depot
.
The depot is initially created with a capacity of 0, so it will not allocate until it is first inserted into.
sourcepub fn with_capacity(capacity: usize) -> Depot
pub fn with_capacity(capacity: usize) -> Depot
Creates an empty Depot
with the specified capacity.
The depot will be able to hold at least capacity elements without reallocating. If capacity is 0, the depot will not allocate.
sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
Returns the number of elements the depot can hold without reallocating.
sourcepub fn insert<K, V>(&mut self, key: K, value: V) where
K: Into<String>,
V: Any + Send + Sync,
pub fn insert<K, V>(&mut self, key: K, value: V) where
K: Into<String>,
V: Any + Send + Sync,
Inserts a key-value pair into the depot.
sourcepub fn contains_key(&self, key: &str) -> bool
pub fn contains_key(&self, key: &str) -> bool
Check is there a value stored in depot with this key.
sourcepub fn get<V>(&self, key: &str) -> Option<&V> where
V: Any + Send,
pub fn get<V>(&self, key: &str) -> Option<&V> where
V: Any + Send,
Immutably borrows value from depot, returing none if value is not present in depot.
sourcepub fn get_mut<V>(&mut self, key: &str) -> Option<&mut V> where
V: Any + Send,
pub fn get_mut<V>(&mut self, key: &str) -> Option<&mut V> where
V: Any + Send,
Mutably borrows value from depot, returing none if value is not present in depot.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Depot
impl Send for Depot
impl !Sync for Depot
impl Unpin for Depot
impl !UnwindSafe for Depot
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more