Skip to main content

MemoryStore

Struct MemoryStore 

Source
pub struct MemoryStore { /* private fields */ }
Expand description

Overrides in a map, for a single process.

Cheap to clone, and clones share one map, so the store can be handed to a Flags and still be written to from an admin route.

The limitation is the obvious one and it is worth saying out loud: an override set here reaches this process and no other. On one machine that is everything; behind a load balancer it means an operator turning a flag off has turned it off for a third of the traffic. This is the right store for a single-process application, for tests, and for a default that works before anybody has chosen a database — and the wrong one for an incident switch across a fleet.

Implementations§

Source§

impl MemoryStore

Source

pub fn new() -> Self

Source

pub fn len(&self) -> usize

How many overrides are stored. Mostly for tests and a status page.

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Clone for MemoryStore

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Default for MemoryStore

Source§

fn default() -> Self

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

impl FlagStore for MemoryStore

Source§

fn name(&self) -> &'static str

The store’s name, for error messages and boot logs.
Source§

fn get<'a>( &'a self, flag: &'a str, scope: &'a Scope, ) -> BoxFuture<'a, Result<Option<bool>>>

The override for one flag and scope: None when nobody has set one. Read more
Source§

fn set<'a>( &'a self, flag: &'a str, scope: &'a Scope, value: bool, ) -> BoxFuture<'a, Result<()>>

Write an override, replacing any that was there.
Source§

fn forget<'a>( &'a self, flag: &'a str, scope: &'a Scope, ) -> BoxFuture<'a, Result<()>>

Remove an override, putting the flag back in the resolver’s hands. Read more
Source§

fn flush(&self) -> BoxFuture<'_, Result<()>>

Remove every override this store holds. Read more

Auto Trait Implementations§

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, dest: *mut u8)

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

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> Same for T

Source§

type Output = T

Should always be Self
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.