Struct salvo::Depot[][src]

pub struct Depot { /* fields omitted */ }

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]

impl Default for Depot[src]

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]

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

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

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

impl<T> Instrument for T[src]

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

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.

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.

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