pub struct SnapshotManager<Db>{ /* private fields */ }
Expand description
Coordinates snapshot download, extraction, validation, and database integration.
The main interface for snapshot operations in production environments. Manages the complete workflow from download to database installation.
§Architecture
SnapshotDownloader
- HTTP/HTTPS and file:// URL handling with retry logicSnapshotExtractor
- Secure tar.xz extraction with path validationSnapshotValidator
- SQLite integrity and content verification- Database integration via
HoprDbGeneralModelOperations::import_logs_db
Implementations§
Source§impl<Db> SnapshotManager<Db>
impl<Db> SnapshotManager<Db>
Sourcepub fn with_db(db: Db) -> Result<Self, SnapshotError>
pub fn with_db(db: Db) -> Result<Self, SnapshotError>
Creates a snapshot manager with database integration.
§Arguments
db
- Database instance implementingHoprDbGeneralModelOperations
§Example
let manager = SnapshotManager::with_db(db)?;
Sourcepub async fn download_and_setup_snapshot(
&self,
url: &str,
data_dir: &Path,
) -> SnapshotResult<SnapshotInfo>
pub async fn download_and_setup_snapshot( &self, url: &str, data_dir: &Path, ) -> SnapshotResult<SnapshotInfo>
Downloads, extracts, validates, and installs a snapshot.
Performs the complete snapshot setup workflow:
- Downloads archive from URL (HTTP/HTTPS/file://)
- Extracts tar.xz archive safely
- Validates database integrity
- Installs via
HoprDbGeneralModelOperations::import_logs_db
- Cleans up temporary files
§Arguments
url
- Snapshot URL (https://
,http://
, orfile://
scheme)data_dir
- Target directory for temporary files during installation
§Returns
SnapshotInfo
containing log count, block count, and metadata on success
§Errors
Returns SnapshotError
for network failures, validation errors, or installation issues
§Examples
// Download from HTTPS
let info = manager
.download_and_setup_snapshot("https://snapshots.hoprnet.org/logs.tar.xz", Path::new("/data"))
.await?;
// Use local file
let info = manager
.download_and_setup_snapshot("file:///backups/snapshot.tar.xz", Path::new("/data"))
.await?;
Auto Trait Implementations§
impl<Db> Freeze for SnapshotManager<Db>where
Db: Freeze,
impl<Db> !RefUnwindSafe for SnapshotManager<Db>
impl<Db> Send for SnapshotManager<Db>
impl<Db> Sync for SnapshotManager<Db>
impl<Db> Unpin for SnapshotManager<Db>where
Db: Unpin,
impl<Db> !UnwindSafe for SnapshotManager<Db>
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more