pub struct QuarantineStore { /* private fields */ }Expand description
In-process quarantine store.
Thread-safe via an internal Mutex. Production deployments may replace
this with a persisted backend by implementing the same functional contract.
Implementations§
Source§impl QuarantineStore
impl QuarantineStore
pub fn new() -> QuarantineStore
Sourcepub fn admit(
&self,
asset_id: impl Into<String>,
asset: NetworkAsset,
origin_peer: impl Into<String>,
) -> bool
pub fn admit( &self, asset_id: impl Into<String>, asset: NetworkAsset, origin_peer: impl Into<String>, ) -> bool
Admit a remote asset into quarantine (state = Pending).
If the asset is already present it is not overwritten; the existing
entry is left unchanged. Returns true when a new entry was inserted.
Sourcepub fn validate_asset(&self, asset_id: &str) -> bool
pub fn validate_asset(&self, asset_id: &str) -> bool
Mark an asset as validated.
Returns true on success, false if the asset was not found.
Sourcepub fn fail_asset(&self, asset_id: &str, reason: impl Into<String>) -> bool
pub fn fail_asset(&self, asset_id: &str, reason: impl Into<String>) -> bool
Mark an asset as failed with a reason.
Returns true on success, false if the asset was not found.
Sourcepub fn get(&self, asset_id: &str) -> Option<QuarantineEntry>
pub fn get(&self, asset_id: &str) -> Option<QuarantineEntry>
Retrieve an entry by asset id.
Sourcepub fn is_selectable(&self, asset_id: &str) -> bool
pub fn is_selectable(&self, asset_id: &str) -> bool
Returns true if asset_id is present and its state is Validated.
Sourcepub fn pending_entries(&self) -> Vec<QuarantineEntry>
pub fn pending_entries(&self) -> Vec<QuarantineEntry>
All entries currently in Pending state.
Sourcepub fn validated_entries(&self) -> Vec<QuarantineEntry>
pub fn validated_entries(&self) -> Vec<QuarantineEntry>
All entries currently in Validated state.
pub fn is_empty(&self) -> bool
Trait Implementations§
Source§impl Default for QuarantineStore
impl Default for QuarantineStore
Source§fn default() -> QuarantineStore
fn default() -> QuarantineStore
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl !Freeze for QuarantineStore
impl RefUnwindSafe for QuarantineStore
impl Send for QuarantineStore
impl Sync for QuarantineStore
impl Unpin for QuarantineStore
impl UnsafeUnpin for QuarantineStore
impl UnwindSafe for QuarantineStore
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more