Struct salvo::Depot[][src]

pub struct Depot { /* fields omitted */ }
Expand description

Depot if for store temp data of current request. Each handler can read or write data to it.

Implementations

impl Depot[src]

pub fn new() -> Depot[src]

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.

pub fn with_capacity(capacity: usize) -> Depot[src]

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.

pub fn insert<K, V>(&mut self, key: K, value: V) where
    V: Any + Send,
    K: Into<String>, 
[src]

Inserts a key-value pair into the depot.

pub fn has<K>(&self, key: K) -> bool where
    K: Into<String>, 
[src]

Check is there a value stored in depot with this key.

pub fn try_borrow<K, V>(&self, key: K) -> Option<&V> where
    V: Any + Send,
    K: Into<String>, 
[src]

Immutably borrows value from depot, returing none if value is not present in depot.

pub fn borrow<K, V>(&self, key: K) -> &V where
    V: Any + Send,
    K: Into<String>, 
[src]

Immutably borrows value from depot.

Panics

Panics if the value is currently mutably borrowed or not present in depot. For a non-panicking variant, use try_borrow.

pub fn try_borrow_mut<K, V>(&mut self, key: K) -> Option<&mut V> where
    V: Any + Send,
    K: Into<String>, 
[src]

Mutably borrows value from depot, returing none if value is not present in depot.

pub fn borrow_mut<K, V>(&mut self, key: K) -> &mut V where
    V: Any + Send,
    K: Into<String>, 
[src]

Mutably borrows value from depot.

Panics

Panics if the value is currently borrowed or not present in depot. For a non-panicking variant, use try_borrow_mut.

pub fn try_take<K, V>(&mut self, key: K) -> Option<V> where
    V: Any + Send,
    K: Into<String>, 
[src]

Take value from depot container.

pub fn take<K, V>(&mut self, key: K) -> V where
    V: Any + Send,
    K: Into<String>, 
[src]

Take value from depot container.

Panics

Panics if the value is not present in depot container. For a non-panicking variant, use try_take.

pub fn transfer(&mut self) -> Depot[src]

Trait Implementations

impl Debug for Depot[src]

pub fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>[src]

Formats the value using the given formatter. Read more

impl Default for Depot[src]

pub fn default() -> Depot[src]

Returns the “default value” for a type. Read more

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

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

fn in_current_span(self) -> Instrumented<Self>[src]

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V