Skip to main content

Maintenance

Struct Maintenance 

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

Backup, restore, export and import operations.

Implementations§

Source§

impl Maintenance

Source

pub const fn supports_backup(&self) -> bool

Whether file-level backup and restore are available.

False for PostgreSQL and externally-supplied databases — use Self::export_to_file for those, or the backend’s own tooling (pg_dump).

Source

pub fn backup_to(&self, backup_path: impl AsRef<Path>) -> Result<BackupReport>

Available on crate feature sqlite only.

Take a consistent backup to backup_path, writing a sidecar manifest.

Safe to call while other threads are writing: the backup is taken with VACUUM INTO inside a read transaction.

§Errors

Returns an error when the instance is not SQLite-backed, or when the backup or its checksum verification fails.

Source

pub fn restore_from( &self, backup_path: impl AsRef<Path>, target_path: impl AsRef<Path>, options: &RestoreOptions, ) -> Result<RestoreReport>

Available on crate feature sqlite only.

Restore a backup over target_path.

This does not affect the currently-open database handle: restore writes a file, and the process must reopen crate::Commerce against the restored path to see the new data. Restoring over the path this instance currently has open is rejected, because the open connection pool would keep serving pages from the replaced file.

§Errors

See stateset_db::maintenance::restore_from. Also errors when target_path is the database this instance has open.

Source

pub fn export_all<W: Write>( &self, writer: &mut W, options: &ExportOptions, ) -> Result<ExportReport>

Write a structured JSON export to writer.

§Errors

Returns an error if a repository read or the write fails.

Source

pub fn export_to_file(&self, path: impl AsRef<Path>) -> Result<ExportReport>

Write a structured JSON export to path, creating parent directories.

§Errors

Returns an error if the file cannot be created or the export fails.

Source

pub fn export_to_file_with( &self, path: impl AsRef<Path>, options: &ExportOptions, ) -> Result<ExportReport>

Self::export_to_file with explicit options.

§Errors

Returns an error if the file cannot be created or the export fails.

Source

pub fn import_all<R: Read>( &self, reader: &mut R, options: &ImportOptions, ) -> Result<ImportReport>

Read a structured JSON export from reader and replay it.

§Errors

See stateset_db::portability::import_all.

Source

pub fn import_from_file( &self, path: impl AsRef<Path>, options: &ImportOptions, ) -> Result<ImportReport>

Read a structured JSON export from path and replay it.

§Errors

Returns an error if the file cannot be read or the import fails.

Source

pub fn exportable_domains(&self) -> Vec<&'static str>

Domains the export covers, in export order.

Source

pub fn importable_domains(&self) -> Vec<&'static str>

Domains the import can write.

Trait Implementations§

Source§

impl Debug for Maintenance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

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