pub struct CsafStorage { /* private fields */ }Expand description
Embedded CSAF document storage backed by redb.
Implementations§
Source§impl CsafStorage
impl CsafStorage
Sourcepub fn open(path: &Path) -> Result<Self>
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.
Sourcepub fn open_temp() -> Result<Self>
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.
Sourcepub fn copy_file_with_snapshot(&self, src: &Path, dst: &Path) -> Result<()>
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.
Sourcepub fn put_document(&self, doc: &CsafDocument) -> Result<()>
pub fn put_document(&self, doc: &CsafDocument) -> Result<()>
Store a CSAF document (create or overwrite).
§Errors
Returns an error if serialization or storage fails.
Sourcepub fn get_document(&self, tracking_id: &str) -> Result<Option<CsafDocument>>
pub fn get_document(&self, tracking_id: &str) -> Result<Option<CsafDocument>>
Sourcepub fn delete_document(&self, tracking_id: &str) -> Result<bool>
pub fn delete_document(&self, tracking_id: &str) -> Result<bool>
Sourcepub fn list_meta(&self, limit: usize, offset: usize) -> Result<Vec<CsafMeta>>
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.
Sourcepub fn count_documents(&self) -> Result<usize>
pub fn count_documents(&self) -> Result<usize>
Sourcepub fn document_exists(&self, tracking_id: &str) -> Result<bool>
pub fn document_exists(&self, tracking_id: &str) -> Result<bool>
Sourcepub fn get_settings(&self) -> Result<Settings>
pub fn get_settings(&self) -> Result<Settings>
Sourcepub fn put_settings(&self, settings: &Settings) -> Result<()>
pub fn put_settings(&self, settings: &Settings) -> Result<()>
Sourcepub fn get_provider_metadata(&self) -> Result<Option<ProviderMetadata>>
pub fn get_provider_metadata(&self) -> Result<Option<ProviderMetadata>>
Sourcepub fn put_provider_metadata(&self, meta: &ProviderMetadata) -> Result<()>
pub fn put_provider_metadata(&self, meta: &ProviderMetadata) -> Result<()>
Sourcepub fn check_storage_up(&self) -> Result<bool>
pub fn check_storage_up(&self) -> Result<bool>
Trait Implementations§
Source§impl Clone for CsafStorage
impl Clone for CsafStorage
Source§fn clone(&self) -> CsafStorage
fn clone(&self) -> CsafStorage
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more