pub(crate) trait Store: Send + 'static {
Show 21 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<()>;
fn update_protocol_recommendations(
&mut self,
valid_after: SystemTime,
protocols: &ProtoStatuses,
) -> Result<()>;
fn cached_protocol_recommendations(
&self,
) -> Result<Option<(SystemTime, ProtoStatuses)>>;
}
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§
Sourcefn is_readonly(&self) -> bool
fn is_readonly(&self) -> bool
Return true if this Store
is opened in read-only mode.
Sourcefn upgrade_to_readwrite(&mut self) -> Result<bool>
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.
Sourcefn expire_all(&mut self, expiration: &ExpirationConfig) -> Result<()>
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.
Sourcefn latest_consensus(
&self,
flavor: ConsensusFlavor,
pending: Option<bool>,
) -> Result<Option<InputString>>
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.
Sourcefn latest_consensus_meta(
&self,
flavor: ConsensusFlavor,
) -> Result<Option<ConsensusMeta>>
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.
Sourcefn consensus_by_sha3_digest_of_signed_part(
&self,
d: &[u8; 32],
) -> Result<Option<(InputString, ConsensusMeta)>>
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.
Sourcefn store_consensus(
&mut self,
cmeta: &ConsensusMeta,
flavor: ConsensusFlavor,
pending: bool,
contents: &str,
) -> Result<()>
fn store_consensus( &mut self, cmeta: &ConsensusMeta, flavor: ConsensusFlavor, pending: bool, contents: &str, ) -> Result<()>
Write a consensus to disk.
Sourcefn mark_consensus_usable(&mut self, cmeta: &ConsensusMeta) -> Result<()>
fn mark_consensus_usable(&mut self, cmeta: &ConsensusMeta) -> Result<()>
Mark the consensus generated from cmeta
as no longer pending.
Sourcefn delete_consensus(&mut self, cmeta: &ConsensusMeta) -> Result<()>
fn delete_consensus(&mut self, cmeta: &ConsensusMeta) -> Result<()>
Remove the consensus generated from cmeta
.
Sourcefn authcerts(
&self,
certs: &[AuthCertKeyIds],
) -> Result<HashMap<AuthCertKeyIds, String>>
fn authcerts( &self, certs: &[AuthCertKeyIds], ) -> Result<HashMap<AuthCertKeyIds, String>>
Read all of the specified authority certs from the cache.
Sourcefn store_authcerts(&mut self, certs: &[(AuthCertMeta, &str)]) -> Result<()>
fn store_authcerts(&mut self, certs: &[(AuthCertMeta, &str)]) -> Result<()>
Save a list of authority certificates to the cache.
Sourcefn microdescs(&self, digests: &[MdDigest]) -> Result<HashMap<MdDigest, String>>
fn microdescs(&self, digests: &[MdDigest]) -> Result<HashMap<MdDigest, String>>
Read all the microdescriptors listed in input
from the cache.
Sourcefn store_microdescs(
&mut self,
digests: &[(&str, &MdDigest)],
when: SystemTime,
) -> Result<()>
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
.
Sourcefn update_microdescs_listed(
&mut self,
digests: &[MdDigest],
when: SystemTime,
) -> Result<()>
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.
Sourcefn routerdescs(&self, digests: &[RdDigest]) -> Result<HashMap<RdDigest, String>>
Available on crate feature routerdesc
only.
fn routerdescs(&self, digests: &[RdDigest]) -> Result<HashMap<RdDigest, String>>
routerdesc
only.Read all the microdescriptors listed in input
from the cache.
Only available when the routerdesc
feature is present.
Sourcefn store_routerdescs(
&mut self,
digests: &[(&str, SystemTime, &RdDigest)],
) -> Result<()>
Available on crate feature routerdesc
only.
fn store_routerdescs( &mut self, digests: &[(&str, SystemTime, &RdDigest)], ) -> Result<()>
routerdesc
only.Store every router descriptors in input
into the cache.
Sourcefn lookup_bridgedesc(
&self,
bridge: &BridgeConfig,
) -> Result<Option<CachedBridgeDescriptor>>
Available on crate feature bridge-client
only.
fn lookup_bridgedesc( &self, bridge: &BridgeConfig, ) -> Result<Option<CachedBridgeDescriptor>>
bridge-client
only.Look up a cached bridge descriptor.
Sourcefn store_bridgedesc(
&mut self,
bridge: &BridgeConfig,
entry: CachedBridgeDescriptor,
until: SystemTime,
) -> Result<()>
Available on crate feature bridge-client
only.
fn store_bridgedesc( &mut self, bridge: &BridgeConfig, entry: CachedBridgeDescriptor, until: SystemTime, ) -> Result<()>
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).
Sourcefn delete_bridgedesc(&mut self, bridge: &BridgeConfig) -> Result<()>
Available on crate feature bridge-client
only.
fn delete_bridgedesc(&mut self, bridge: &BridgeConfig) -> Result<()>
bridge-client
only.Delete a cached bridge descriptor for this bridge.
It’s not an error if it’s not present.
Sourcefn update_protocol_recommendations(
&mut self,
valid_after: SystemTime,
protocols: &ProtoStatuses,
) -> Result<()>
fn update_protocol_recommendations( &mut self, valid_after: SystemTime, protocols: &ProtoStatuses, ) -> Result<()>
Try to update our cached protocol recommendations to those listed in protocols
.
Sourcefn cached_protocol_recommendations(
&self,
) -> Result<Option<(SystemTime, ProtoStatuses)>>
fn cached_protocol_recommendations( &self, ) -> Result<Option<(SystemTime, ProtoStatuses)>>
Return our most recent cached protocol recommendations.