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
impl SiteMemoryStore
Sourcepub fn new(capacity: usize) -> SiteMemoryStore
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.
Sourcepub fn capacity(&self) -> usize
pub fn capacity(&self) -> usize
How many slots the table has, which is the most sites it can remember at once.
Sourcepub fn len(&self) -> usize
pub fn len(&self) -> usize
How many slots hold a site right now.
Never more than SiteMemoryStore::capacity, which is the property
worth checking.
Sourcepub fn get(&self, url: &Url) -> Option<SiteMemory>
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.
Sourcepub fn observe(&self, url: &Url, outcome: &AttemptOutcome)
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.
Sourcepub fn remember(&self, url: &Url, memory: SiteMemory)
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.