Skip to main content

CsafStorage

Struct CsafStorage 

Source
pub struct CsafStorage { /* private fields */ }
Expand description

Embedded CSAF document storage backed by redb.

Implementations§

Source§

impl CsafStorage

Source

pub fn open(path: &Path) -> Result<Self>

Open or create the redb database at the given path.

§Errors

Returns an error if the database cannot be opened.

Source

pub fn open_temp() -> Result<Self>

Open a temporary in-memory-like database (for tests).

§Errors

Returns an error if the temporary database cannot be created.

Source

pub fn copy_file_with_snapshot(&self, src: &Path, dst: &Path) -> Result<()>

Copy the on-disk redb file at src to dst while holding a read transaction on the live handle to pin an MVCC snapshot. This avoids the “Database already open” lock collision that a second redb::Database::open would trigger when the server is running against the same file.

The destination is then re-opened to verify the copy is a valid redb file; the file is deleted and an error returned if the verification fails.

§Errors

Returns an error if the read txn can’t be acquired, the file can’t be copied, or the copy fails integrity verification.

Source

pub fn put_document(&self, doc: &CsafDocument) -> Result<()>

Store a CSAF document (create or overwrite).

§Errors

Returns an error if serialization or storage fails.

Source

pub fn get_document(&self, tracking_id: &str) -> Result<Option<CsafDocument>>

Retrieve a CSAF document by tracking ID.

§Errors

Returns an error if the read fails.

Source

pub fn get_document_json(&self, tracking_id: &str) -> Result<Option<Value>>

Retrieve a CSAF document as raw JSON value.

§Errors

Returns an error if the read fails.

Source

pub fn delete_document(&self, tracking_id: &str) -> Result<bool>

Delete a CSAF document by tracking ID.

§Errors

Returns an error if the delete fails.

Source

pub fn list_meta(&self, limit: usize, offset: usize) -> Result<Vec<CsafMeta>>

List all CSAF document metadata, ordered by tracking ID.

§Errors

Returns an error if the read fails.

Source

pub fn count_documents(&self) -> Result<usize>

Count total number of stored documents.

§Errors

Returns an error if the read fails.

Source

pub fn document_exists(&self, tracking_id: &str) -> Result<bool>

Check if a document exists.

§Errors

Returns an error if the read fails.

Source

pub fn list_by_category(&self, category: &str) -> Result<Vec<String>>

List tracking IDs for a given category.

§Errors

Returns an error if the read fails.

Source

pub fn get_settings(&self) -> Result<Settings>

Load application settings from storage.

§Errors

Returns an error if the read fails.

Source

pub fn put_settings(&self, settings: &Settings) -> Result<()>

Save application settings to storage.

§Errors

Returns an error if serialization or storage fails.

Source

pub fn get_provider_metadata(&self) -> Result<Option<ProviderMetadata>>

Load provider metadata from storage.

§Errors

Returns an error if the read fails.

Source

pub fn put_provider_metadata(&self, meta: &ProviderMetadata) -> Result<()>

Save provider metadata to storage.

§Errors

Returns an error if serialization or storage fails.

Source

pub fn check_storage_up(&self) -> Result<bool>

Check if storage is operational.

§Errors

Returns an error if the check fails.

Trait Implementations§

Source§

impl Clone for CsafStorage

Source§

fn clone(&self) -> CsafStorage

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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