pub struct TrustStore {
pub trust_path: PathBuf,
pub allowlist_path: PathBuf,
pub records: TrustFile,
pub allowlist: MarketplacesAllowlist,
}Expand description
In-memory wrapper around the two on-disk files.
Fields§
§trust_path: PathBufPath to plugins.json.
allowlist_path: PathBufPath to marketplaces-allowlist.json.
records: TrustFileCached trust records.
allowlist: MarketplacesAllowlistCached marketplace allowlist.
Implementations§
Source§impl TrustStore
impl TrustStore
Sourcepub fn open(
trust_path: PathBuf,
allowlist_path: PathBuf,
) -> Result<Self, PluginError>
pub fn open( trust_path: PathBuf, allowlist_path: PathBuf, ) -> Result<Self, PluginError>
Construct a store at the given paths and lazily load both files (if they exist; missing files yield empty defaults).
§Errors
Returns PluginError::Io on read failure other than NotFound
and PluginError::Parse on malformed JSON.
Sourcepub fn default_paths() -> (PathBuf, PathBuf)
pub fn default_paths() -> (PathBuf, PathBuf)
Default on-disk paths under $HOME / $XDG_DATA_HOME.
Sourcepub fn open_default() -> Result<Self, PluginError>
pub fn open_default() -> Result<Self, PluginError>
Sourcepub fn save(&self) -> Result<(), PluginError>
pub fn save(&self) -> Result<(), PluginError>
Persist both files to disk (best-effort; creates parent dirs).
§Errors
Returns PluginError::Io on write failure.
Sourcepub fn is_marketplace_approved(&self, url: &str) -> bool
pub fn is_marketplace_approved(&self, url: &str) -> bool
Returns true if the marketplace URL was previously approved.
Sourcepub fn approve_marketplace(&mut self, url: &str)
pub fn approve_marketplace(&mut self, url: &str)
Mark a marketplace URL as approved (idempotent).
Sourcepub fn get(&self, name: &str) -> Option<&PluginTrustRecord>
pub fn get(&self, name: &str) -> Option<&PluginTrustRecord>
Return the existing trust record for name, if any.
Sourcepub fn record(&mut self, name: &str, record: PluginTrustRecord)
pub fn record(&mut self, name: &str, record: PluginTrustRecord)
Record an install. Replaces any existing record for the same name.
Sourcepub fn forget(&mut self, name: &str) -> Option<PluginTrustRecord>
pub fn forget(&mut self, name: &str) -> Option<PluginTrustRecord>
Drop the trust record for name. Returns the previous record if any.
Trait Implementations§
Source§impl Clone for TrustStore
impl Clone for TrustStore
Source§fn clone(&self) -> TrustStore
fn clone(&self) -> TrustStore
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more