Skip to main content

Error

Enum Error 

Source
#[non_exhaustive]
pub enum Error {
Show 14 variants TooShort, BadMagic, BadPageSize(u32), PageOutOfRange(u32), NotATablePage(u8), TruncatedCell, MalformedSerialType { serial: i64, offset: usize, }, TooManyPages, MalformedFreelist, MalformedOverflow, BadJournalPageSize(u32), JournalModeConflict, Io(ErrorKind), Decrypt(DecryptError),
}
Expand description

Errors that can arise while reading a SQLite database, all recoverable — the reader never panics on malformed input.

#[non_exhaustive] so naming a newly-recognised malformation is an additive change. It is applied in the same release that adds Error::MalformedSerialType, because that addition is breaking either way and doing both at once spends the break once instead of twice.

Variants (Non-exhaustive)§

This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
§

TooShort

File is shorter than the 100-byte header.

§

BadMagic

First 16 bytes are not the SQLite format 3\0 magic.

§

BadPageSize(u32)

Page-size field is not a power of two in [512, 65536].

§

PageOutOfRange(u32)

A page number referenced by the b-tree is out of range for the file.

§

NotATablePage(u8)

A b-tree page had an unexpected type byte where a table page was required.

§

TruncatedCell

A cell pointer or payload ran past the end of its page.

§

MalformedSerialType

A record’s serial type was negative, so it names no value at all. A serial type is a varint, and a damaged record decodes one as a negative i64. Carries the offending value and the body offset it was read for (Show-the-unrecognized-value).

Fields

§serial: i64

The serial type as decoded, verbatim.

§offset: usize

Offset into the cell body the value would have started at.

§

TooManyPages

The b-tree was deeper / wider than the safety cap allows.

§

MalformedFreelist

The freelist trunk chain cycled or exceeded the file’s page count.

§

MalformedOverflow

An overflow-page chain cycled or exceeded the file’s page count.

§

BadJournalPageSize(u32)

A rollback-journal page size was not a power of two in [512, 65536]. Carries the offending value (Show-the-unrecognized-value).

§

JournalModeConflict

A rollback journal was applied to a database opened WAL-applied, or whose page size disagrees with the journal’s. WAL and rollback-journal modes are mutually exclusive timelines and must not be overlaid.

§

Io(ErrorKind)

The file could not be opened or read (an I/O failure via Database::open_path, not a malformed database). Carries the std::io::ErrorKind (show-the-unrecognized-value).

§

Decrypt(DecryptError)

SQLCipher decryption failed (wrong key, unsupported cipher parameters, or a failed page authentication) via Database::open_encrypted. Carries the underlying sqlcipher::DecryptError (show-the-unrecognized-value).

Trait Implementations§

Source§

impl Clone for Error

Source§

fn clone(&self) -> Error

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Error

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for Error

Source§

impl From<DecryptError> for Error

Source§

fn from(e: DecryptError) -> Self

Converts to this type from the input type.
Source§

impl From<Error> for Error

Source§

fn from(e: Error) -> Self

Converts to this type from the input type.
Source§

impl PartialEq for Error

Source§

fn eq(&self, other: &Error) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Error

Auto Trait Implementations§

§

impl Freeze for Error

§

impl RefUnwindSafe for Error

§

impl Send for Error

§

impl Sync for Error

§

impl Unpin for Error

§

impl UnsafeUnpin for Error

§

impl UnwindSafe for Error

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, 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.