Trait tor_dirmgr::storage::Store

source ·
pub(crate) trait Store: Send + 'static {
Show 19 methods // Required methods fn is_readonly(&self) -> bool; fn upgrade_to_readwrite(&mut self) -> Result<bool>; fn expire_all(&mut self, expiration: &ExpirationConfig) -> Result<()>; fn latest_consensus( &self, flavor: ConsensusFlavor, pending: Option<bool> ) -> Result<Option<InputString>>; fn latest_consensus_meta( &self, flavor: ConsensusFlavor ) -> Result<Option<ConsensusMeta>>; fn consensus_by_sha3_digest_of_signed_part( &self, d: &[u8; 32] ) -> Result<Option<(InputString, ConsensusMeta)>>; fn store_consensus( &mut self, cmeta: &ConsensusMeta, flavor: ConsensusFlavor, pending: bool, contents: &str ) -> Result<()>; fn mark_consensus_usable(&mut self, cmeta: &ConsensusMeta) -> Result<()>; fn delete_consensus(&mut self, cmeta: &ConsensusMeta) -> Result<()>; fn authcerts( &self, certs: &[AuthCertKeyIds] ) -> Result<HashMap<AuthCertKeyIds, String>>; fn store_authcerts(&mut self, certs: &[(AuthCertMeta, &str)]) -> Result<()>; fn microdescs( &self, digests: &[MdDigest] ) -> Result<HashMap<MdDigest, String>>; fn store_microdescs( &mut self, digests: &[(&str, &MdDigest)], when: SystemTime ) -> Result<()>; fn update_microdescs_listed( &mut self, digests: &[MdDigest], when: SystemTime ) -> Result<()>; fn routerdescs( &self, digests: &[RdDigest] ) -> Result<HashMap<RdDigest, String>>; fn store_routerdescs( &mut self, digests: &[(&str, SystemTime, &RdDigest)] ) -> Result<()>; fn lookup_bridgedesc( &self, bridge: &BridgeConfig ) -> Result<Option<CachedBridgeDescriptor>>; fn store_bridgedesc( &mut self, bridge: &BridgeConfig, entry: CachedBridgeDescriptor, until: SystemTime ) -> Result<()>; fn delete_bridgedesc(&mut self, bridge: &BridgeConfig) -> Result<()>;
}
Expand description

Representation of a storage.

When creating an instance of this Store, it should try to grab the lock during initialization (is_readonly() iff some other implementation grabbed it).

Required Methods§

source

fn is_readonly(&self) -> bool

Return true if this Store is opened in read-only mode.

source

fn upgrade_to_readwrite(&mut self) -> Result<bool>

Try to upgrade from a read-only connection to a read-write connection.

Return true on success; false if another process had the lock.

source

fn expire_all(&mut self, expiration: &ExpirationConfig) -> Result<()>

Delete all completely-expired objects from the database.

This is pretty conservative, and only removes things that are definitely past their good-by date.

source

fn latest_consensus( &self, flavor: ConsensusFlavor, pending: Option<bool> ) -> Result<Option<InputString>>

Load the latest consensus from disk.

If pending is given, we will only return a consensus with the given “pending” status. (A pending consensus doesn’t have enough descriptors yet.) If pending_ok is None, we’ll return a consensus with any pending status.

source

fn latest_consensus_meta( &self, flavor: ConsensusFlavor ) -> Result<Option<ConsensusMeta>>

Return the information about the latest non-pending consensus, including its valid-after time and digest.

source

fn consensus_by_sha3_digest_of_signed_part( &self, d: &[u8; 32] ) -> Result<Option<(InputString, ConsensusMeta)>>

Try to read the consensus whose SHA3-256 digests is the provided value, and its metadata.

source

fn store_consensus( &mut self, cmeta: &ConsensusMeta, flavor: ConsensusFlavor, pending: bool, contents: &str ) -> Result<()>

Write a consensus to disk.

source

fn mark_consensus_usable(&mut self, cmeta: &ConsensusMeta) -> Result<()>

Mark the consensus generated from cmeta as no longer pending.

source

fn delete_consensus(&mut self, cmeta: &ConsensusMeta) -> Result<()>

Remove the consensus generated from cmeta.

source

fn authcerts( &self, certs: &[AuthCertKeyIds] ) -> Result<HashMap<AuthCertKeyIds, String>>

Read all of the specified authority certs from the cache.

source

fn store_authcerts(&mut self, certs: &[(AuthCertMeta, &str)]) -> Result<()>

Save a list of authority certificates to the cache.

source

fn microdescs(&self, digests: &[MdDigest]) -> Result<HashMap<MdDigest, String>>

Read all the microdescriptors listed in input from the cache.

source

fn store_microdescs( &mut self, digests: &[(&str, &MdDigest)], when: SystemTime ) -> Result<()>

Store every microdescriptor in input into the cache, and say that it was last listed at when.

source

fn update_microdescs_listed( &mut self, digests: &[MdDigest], when: SystemTime ) -> Result<()>

Update the last-listed time of every microdescriptor in input to when or later.

source

fn routerdescs(&self, digests: &[RdDigest]) -> Result<HashMap<RdDigest, String>>

Available on crate feature routerdesc only.

Read all the microdescriptors listed in input from the cache.

Only available when the routerdesc feature is present.

source

fn store_routerdescs( &mut self, digests: &[(&str, SystemTime, &RdDigest)] ) -> Result<()>

Available on crate feature routerdesc only.

Store every router descriptors in input into the cache.

source

fn lookup_bridgedesc( &self, bridge: &BridgeConfig ) -> Result<Option<CachedBridgeDescriptor>>

Available on crate feature bridge-client only.

Look up a cached bridge descriptor.

source

fn store_bridgedesc( &mut self, bridge: &BridgeConfig, entry: CachedBridgeDescriptor, until: SystemTime ) -> Result<()>

Available on crate feature bridge-client only.

Store a cached bridge descriptor.

This entry will be deleted some time after until (but the caller is not allowed to rely on either timely deletion, or retention until that time).

source

fn delete_bridgedesc(&mut self, bridge: &BridgeConfig) -> Result<()>

Available on crate feature bridge-client only.

Delete a cached bridge descriptor for this bridge.

It’s not an error if it’s not present.

Implementors§