pub enum DbError {
Connect(Error),
Migrate(MigrateError),
Query(Error),
InvalidEnumValue {
column: &'static str,
value: String,
},
InvalidMvActuationFinalStatus,
InvalidJsonShape {
column: &'static str,
source: Error,
},
TemplateInUse {
id: i64,
},
BackupDestinationExists(PathBuf),
InvalidBackup(String),
Io(Error),
DatabaseInUse(PathBuf),
}Expand description
Everything that can go wrong opening the database, running migrations, or executing a query.
Variants§
Connect(Error)
Migrate(MigrateError)
Query(Error)
InvalidEnumValue
A value read back from a TEXT enum column didn’t match any known
variant. This can only happen if the row was written by something
other than this crate (or a future version wrote a variant this
version doesn’t know about) — the CHECK constraints on every
enum-shaped column prevent the database itself from ever storing an
invalid value.
InvalidMvActuationFinalStatus
An MV-actuation finalization API was given crate::models::MvActuationStatus::Pending.
Pending is the initial state inserted by
crate::models::TuneMvActuationRow::insert_pending, not a terminal result.
InvalidJsonShape
A JSON column (tune_runs.template_snapshot_json/tags_json/
timing_metrics_json, dcs_templates.versions_json) held syntactically valid JSON
– the schema’s CHECK (json_valid(...)) already guarantees that much – but it
didn’t deserialize into the Rust shape the column is supposed to hold. This can
happen honestly, not just from external tampering: an older snapshot can predate a
field a later release added to its typed representation.
TemplateInUse
crate::models::DcsTemplateRow::delete targeted a template that at least one
loops row still references. The schema’s ON DELETE RESTRICT foreign key is what
actually enforces this; this variant exists so bhtune-cli’s template delete can
turn the resulting SQLite foreign-key-violation error into a message naming the
template rather than a raw SQL error, without needing its own sqlx dependency just
to inspect the error kind.
BackupDestinationExists(PathBuf)
crate::backup::backup_to’s destination already exists. Refused rather than
silently overwritten — clobbering a previous backup because of a reused filename
would itself be a data-loss bug.
InvalidBackup(String)
crate::backup::restore_from (or crate::backup::backup_to’s own post-write
check) determined a file is not a usable bhtune backup: it failed
PRAGMA integrity_check, or it doesn’t contain a tune_runs table.
Io(Error)
A filesystem operation during crate::backup::backup_to/
crate::backup::restore_from (copying, renaming, or removing a file) failed.
DatabaseInUse(PathBuf)
crate::backup::restore_from found another connection (in this process or
another) still attached to the live database. Restoring while that’s true risks
desynchronizing whatever holds it: its view of the file would silently stop matching
what’s on disk the moment the restore replaces it.
Trait Implementations§
Source§impl Error for DbError
impl Error for DbError
Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Auto Trait Implementations§
impl !RefUnwindSafe for DbError
impl !UnwindSafe for DbError
impl Freeze for DbError
impl Send for DbError
impl Sync for DbError
impl Unpin for DbError
impl UnsafeUnpin for DbError
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
§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>
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>
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