Skip to main content

QuarantineStore

Struct QuarantineStore 

Source
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

Source

pub fn new() -> QuarantineStore

Source

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.

Source

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.

Source

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.

Source

pub fn get(&self, asset_id: &str) -> Option<QuarantineEntry>

Retrieve an entry by asset id.

Source

pub fn is_selectable(&self, asset_id: &str) -> bool

Returns true if asset_id is present and its state is Validated.

Source

pub fn pending_entries(&self) -> Vec<QuarantineEntry>

All entries currently in Pending state.

Source

pub fn validated_entries(&self) -> Vec<QuarantineEntry>

All entries currently in Validated state.

Source

pub fn len(&self) -> usize

Total number of entries.

Source

pub fn is_empty(&self) -> bool

Trait Implementations§

Source§

impl Default for QuarantineStore

Source§

fn default() -> QuarantineStore

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more