Skip to main content

SiteMemoryStore

Struct SiteMemoryStore 

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

One site’s record, keyed by its registrable name.

Cheap to share: a store is allocated once and read through a shared reference from any number of tasks.

Implementations§

Source§

impl SiteMemoryStore

Source

pub fn new(capacity: usize) -> SiteMemoryStore

A store with room for about this many sites.

Zero disables memory without allocating a table. Otherwise the figure is rounded up to a power of two and held between 16 and 65536, so the table can be indexed with a mask and so no caller can ask for a store that is not bounded.

Source

pub fn capacity(&self) -> usize

How many slots the table has, which is the most sites it can remember at once.

Source

pub fn len(&self) -> usize

How many slots hold a site right now.

Never more than SiteMemoryStore::capacity, which is the property worth checking.

Source

pub fn is_empty(&self) -> bool

Whether nothing has been recorded yet.

Source

pub fn get(&self, url: &Url) -> Option<SiteMemory>

What is remembered about the site this address belongs to.

None when nothing is, which is what a cold start looks like and what the router is built to handle.

Source

pub fn observe(&self, url: &Url, outcome: &AttemptOutcome)

Fold one attempt into what is remembered about this site.

A site that has not been seen before takes the slot its key maps to, evicting whatever was there. That is the bound: a slot per site, never a slot more.

Source

pub fn remember(&self, url: &Url, memory: SiteMemory)

Write a record directly, replacing whatever was there.

For a caller that keeps its own records elsewhere and wants this process to start from them rather than relearn them.

Source

pub fn clear(&self)

Forget everything.

Trait Implementations§

Source§

impl Debug for SiteMemoryStore

Source§

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

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

impl Default for SiteMemoryStore

Source§

fn default() -> SiteMemoryStore

Returns the “default value” for a type. 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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

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