Struct Store

Source
pub struct Store {
    store: Arc<dyn StoreBackend>,
}
Expand description

A wrapper around any StoreBackend, providing access to the underlying store along some with extra things like logging.

Fields§

§store: Arc<dyn StoreBackend>

Implementations§

Source§

impl Store

Source

pub async fn new( store_type: BackendType, config: &HashMap<String, String>, ) -> Result<Self>

Create a new instance of this Store. Configuration is backend-specific and is provided as a HashMap from string keys to string values, that are parsed by the backend as needed.

§Errors

This function returns an error if the store could not be initialized. This may happen if the configuration is invalid or for other backend-specific reasons (such as a file not being createable or a network connection not being establishable, etc.).

Source

pub fn backend_name(&self) -> &'static str

Get the underlying implementation’s name. The name (used in e.g. the configuration) of the backend store implementing this trait must be a human-readable name using only ‘a’-‘z’, ‘0’-‘9’, and ‘_’.

Source

pub async fn get_redirect(&self, from: Id) -> Result<Option<Link>>

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.

§Error

An error is only returned if something actually fails; if we don’t know if a link exists or not, or what it is. A link not existing is not considered an error.

Source

pub async fn set_redirect(&self, from: Id, to: Link) -> Result<Option<Link>>

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.

§Storage Guarantees

If an Ok is returned, the new value was definitely set / processed / saved, and will be available on next request. If an Err is returned, the value must not have been set / modified, insofar as that is possible to determine from the backend.

Source

pub async fn rem_redirect(&self, from: Id) -> Result<Option<Link>>

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.

§Storage Guarantees

If an Ok is returned, the new value was definitely removed / processed / saved, and will be unavailable on next request. If an Err is returned, the value must not have been removed / modified, insofar as that is possible to determine from the backend.

Source

pub async fn get_vanity(&self, from: Normalized) -> Result<Option<Id>>

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.

§Error

An error is only returned if something actually fails; if we don’t know if a link exists or not, or what it is. A link not existing is not considered an error.

Source

pub async fn set_vanity(&self, from: Normalized, to: Id) -> Result<Option<Id>>

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.

§Storage Guarantees

If an Ok is returned, the new value was definitely set / processed / saved, and will be available on next request. If an Err is returned, the value must not have been set / modified, insofar as that is possible to determine from the backend.

Source

pub async fn rem_vanity(&self, from: Normalized) -> Result<Option<Id>>

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.

§Storage Guarantees

If an Ok is returned, the new value was definitely removed / processed / saved, and will be unavailable on next request. If an Err is returned, the value must not have been removed / modified, insofar as that is possible to determine from the backend.

Source

pub async fn get_statistics( &self, description: StatisticDescription, ) -> Result<impl Iterator<Item = (Statistic, StatisticValue)>>

Get statistics’ values by their description. Returns all matching statistics and their values for the provided statistic description. Statistics not having been collected is not an error, if no matching statistics are found, an empty iterator is returned.

§Error

An error is only returned if something fails when it should have worked. A statistic not existing or the store not supporting statistics is not considered an error.

Source

pub fn incr_statistics<I>(&self, statistics: I)
where I: IntoIterator<Item = Statistic> + Send + 'static, <I as IntoIterator>::IntoIter: Send,

Increment multiple statistics’ count for the given id and/or vanity path. Each of the provided statistics’ values for the provided id and vanity path are incremented by 1 in a spawned tokio task in the background.

§Error

This function failing in any way is not considered an error, because statistics are done on a best-effort basis. However, any errors that occur are logged.

Source

pub async fn rem_statistics( &self, description: StatisticDescription, ) -> Result<impl Iterator<Item = (Statistic, StatisticValue)>>

Remove statistics by their description. Deletes all statistics that match the provided description 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 iterator is returned.

§Error

An error is only returned if something fails when it should have worked. A statistic not existing or the store not supporting statistics is not considered an error.

Trait Implementations§

Source§

impl Clone for Store

Source§

fn clone(&self) -> Store

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Store

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> FromRef<T> for T
where T: Clone,

§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
§

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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