Struct Memory

Source
pub struct Memory {
    redirects: RwLock<HashMap<Id, Link>>,
    vanity: RwLock<HashMap<Normalized, Id>>,
    stats: RwLock<HashMap<Statistic, StatisticValue>>,
}
Expand description

A fully in-memory StoreBackend implementation useful for testing. Not recommended for production, as this lacks any data persistence or backups.

§Configuration

Store backend name: memory

Configuration: none

Fields§

§redirects: RwLock<HashMap<Id, Link>>§vanity: RwLock<HashMap<Normalized, Id>>§stats: RwLock<HashMap<Statistic, StatisticValue>>

Trait Implementations§

Source§

impl Debug for Store

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl StoreBackend for Store

Source§

fn store_type() -> BackendType
where Self: Sized,

Get this implementation’s backend store type. This is used in e.g. the configuration.
Source§

fn get_store_type(&self) -> BackendType

Get this implementation’s backend store type. This can be used on trait objects, but is otherwise equivalent to calling Self::store_type().
Source§

fn new<'life0, 'async_trait>( _config: &'life0 HashMap<String, String>, ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Create a new instance of this StoreBackend. Configuration is provided as a collection of pico-args arguments beginning with --store-. For details about configuring each store backend, see that backend’s documentation.
Source§

fn get_redirect<'life0, 'async_trait>( &'life0 self, from: Id, ) -> Pin<Box<dyn Future<Output = Result<Option<Link>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a redirect. Returns the full to link corresponding to the from links ID. A link not existing is not an error, if no matching link is found, Ok(None) is returned. Read more
Source§

fn set_redirect<'life0, 'async_trait>( &'life0 self, from: Id, to: Link, ) -> Pin<Box<dyn Future<Output = Result<Option<Link>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set a redirect. from is the ID of the link, while to is the full destination link. If a mapping with this ID already exists, it must be changed to the new one, returning the old one. Read more
Source§

fn rem_redirect<'life0, 'async_trait>( &'life0 self, from: Id, ) -> Pin<Box<dyn Future<Output = Result<Option<Link>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a redirect. from is the ID of the links link to be removed. Returns the old value of the mapping or None if there was no such mapping. Read more
Source§

fn get_vanity<'life0, 'async_trait>( &'life0 self, from: Normalized, ) -> Pin<Box<dyn Future<Output = Result<Option<Id>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a vanity path’s ID. Returns the ID of the to link corresponding to the from vanity path. An ID not existing is not an error, if no matching ID is found, None is returned. Read more
Source§

fn set_vanity<'life0, 'async_trait>( &'life0 self, from: Normalized, to: Id, ) -> Pin<Box<dyn Future<Output = Result<Option<Id>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Set a vanity path for an ID. from is the vanity path of the links ID, while to is the ID itself. If a vanity link with this path already exists, it must be changed to the new one, returning the old one. Read more
Source§

fn rem_vanity<'life0, 'async_trait>( &'life0 self, from: Normalized, ) -> Pin<Box<dyn Future<Output = Result<Option<Id>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove a vanity path. from is the vanity path to be removed. Returns the old value of the mapping or None if there was no such mapping. Read more
Source§

fn get_statistics<'life0, 'async_trait>( &'life0 self, description: StatisticDescription, ) -> Pin<Box<dyn Future<Output = Result<Vec<(Statistic, StatisticValue)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get statistics’ values by their description. Returns all matching Statistics and their values for the provided StatisticDescription. Statistics not having been collected is not an error, if no matching statistics are found, an empty Vec is returned. Read more
Source§

fn incr_statistic<'life0, 'async_trait>( &'life0 self, statistic: Statistic, ) -> Pin<Box<dyn Future<Output = Result<Option<StatisticValue>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Increment a statistic’s count. The provided Statistic’s value is incremented by 1. Returns the new value of the statistic after the increment, or None if the statistic wasn’t recorded or its new value is not known. Read more
Source§

fn rem_statistics<'life0, 'async_trait>( &'life0 self, description: StatisticDescription, ) -> Pin<Box<dyn Future<Output = Result<Vec<(Statistic, StatisticValue)>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Remove statistics by their description. Deletes all Statistics that match the provided StatisticDescription and returns their values before they were deleted, if they’re available. A statistic not having been collected is not an error, if no matching statistics are found, an empty Vec is returned. Read more

Auto Trait Implementations§

§

impl !Freeze for Store

§

impl !RefUnwindSafe for Store

§

impl Send for Store

§

impl Sync for Store

§

impl Unpin for Store

§

impl UnwindSafe for Store

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T> Instrument for T

Source§

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

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

fn in_current_span(self) -> Instrumented<Self>

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

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> IntoRequest<T> for T

Source§

fn into_request(self) -> Request<T>

Wrap the input message T in a tonic::Request
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T