Skip to main content

MnemoError

Enum MnemoError 

Source
#[non_exhaustive]
pub enum MnemoError {
Show 23 variants Io(Error), BadMagic, UnsupportedVersion(u16), HeaderChecksum, WrongPassphrase, PageAuthFailed(u64), HeaderTampered, Crypto(String), Kdf(String), Serialize(String), NotFound(String), DimensionMismatch { expected: usize, got: usize, }, Invalid(String),
#[non_exhaustive]
Locked { path: PathBuf, holder: Option<String>, }, MaybeStored(String), ReplacedDuringWrite { path: PathBuf, }, Cancelled, Unsupported(String),
#[non_exhaustive]
Replaced { path: PathBuf, shared: bool, missing: bool, }, ReadOnly, NeedsWriteOpen { reason: &'static str, }, FormatTooOld { version: u16, }, EmbedderMismatch { stored: Box<EmbedderIdentity>, given: Box<EmbedderIdentity>, },
}
Expand description

All errors the Mnemo engine can produce.

#[non_exhaustive] (v0.14): new variants can arrive in a minor release, so a match needs a catch-all arm.

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

Io(Error)

An underlying I/O failure.

§

BadMagic

The file does not begin with the Mnemo magic bytes.

§

UnsupportedVersion(u16)

The on-disk format version is newer than this build understands.

§

HeaderChecksum

The header page failed its CRC check — a torn page-0 write or corruption. crate::Mnemo::open tries to repair this from the WAL.

§

WrongPassphrase

Returned when the supplied passphrase fails to unwrap the data key. The failure is an authenticated-decryption failure, so it is indistinguishable from a tampered key blob — both are rejected cleanly.

§

PageAuthFailed(u64)

AEAD authentication failed for a page: corruption or tampering.

§

HeaderTampered

The v7 header seal failed authentication — at least one mutable header field has been rewritten without the DEK. Open refuses to proceed so a silent rollback or pointer-rewrite attack can’t surface stale data.

§

Crypto(String)

A low-level cryptographic operation failed.

§

Kdf(String)

Argon2id key derivation failed.

§

Serialize(String)

A record failed to (de)serialize.

§

NotFound(String)

No memory exists with the requested ID.

§

DimensionMismatch

A vector did not match the database’s configured dimensionality.

Fields

§expected: usize

Dimensionality the database was created with.

§got: usize

Dimensionality of the offending vector.

§

Invalid(String)

A caller-supplied argument was invalid.

§

#[non_exhaustive]
Locked

Another process (or another handle in this process) already holds a conflicting OS file lock on the target .mnemo file. Write handles take an exclusive lock; read-only handles take a shared lock. Two writers or a writer + reader will collide.

A shared-mode call that waits out its deadline also returns this, with holder naming the long operation that holds the file when one said so (12.4: “compact since 12:01 (pid 4242, mnemo)”).

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§path: PathBuf

The path whose lock was requested and refused.

§holder: Option<String>

What holds the file, when the holder left a note: a shared-mode long operation (compaction, an index build, an import) writes one.

§

MaybeStored(String)

A shared-mode write failed after its commit point and the handle couldn’t finish the commit itself, so the write may have been stored: the next process to open the file finishes it. Don’t retry the same write blindly; check whether it’s there.

§

ReplacedDuringWrite

A shared-mode write committed to a file that something renamed away from the handle’s path during the commit (an older mnemo compact, say). The write isn’t in the file now at the path.

Fields

§path: PathBuf

The path that now names a different file.

§

Cancelled

A shared-mode call was cancelled from another thread (an iOS background activity’s expiry handler, say) while it waited for the file’s lock. It released every lock it held and changed nothing.

§

Unsupported(String)

This build or this location can’t do what was asked: shared mode on a network or synced filesystem (without allow_network_fs), or on a Windows build made with Rust before 1.85. The message says which.

§

#[non_exhaustive]
Replaced

The file at this handle’s path is no longer the file the handle opened: something renamed another file over it (a compaction in another process, or another program), or the file was moved or removed (missing). Writing would go to a file nobody finds at the path, so the handle refuses, and writes nothing. A plain handle: reopen the path to use the file that’s there now (crate::Mnemo::try_close hands the handle back). A shared handle (shared): the rename came between the window’s identity check and its commit (an older build’s compaction renames without its lock); calling again is safe, and the next call follows the new file.

Fields

This variant is marked as non-exhaustive
Non-exhaustive enum variants could have additional fields added in future. Therefore, non-exhaustive enum variants cannot be constructed in external crates and cannot be matched against.
§path: PathBuf

The handle’s path, which no longer names the file it opened.

§shared: bool

Raised in a shared-mode write window, where the next call follows the new file by itself.

§missing: bool

Nothing is at the path any more: the file was moved or removed, rather than another file renamed over it.

§

ReadOnly

A mutation was attempted on a handle opened via crate::Mnemo::open_read_only. Reopen read-write to mutate.

§

NeedsWriteOpen

A read-only open was requested but the file has pending on-disk work that requires a write handle to complete — a committed-but-unchecked WAL transaction, or a format-version migration older than the current VERSION. Open read-write once, close cleanly, then reopen read-only.

On a file older than v9 (which no build opens read-write since the v8 sunset) the reason itself says to run mnemo compact, which completes the work and converts the file, and the generic advice is left off.

Fields

§reason: &'static str

Human-readable reason (e.g. "pending WAL recovery").

§

FormatTooOld

The v8 sunset (v0.13): the file’s format is older than v9, so it can’t be opened read-write. A v8 file still opens read-only (crate::Mnemo::open_read_only); mnemo compact (or crate::Mnemo::compact_file) converts any v4–v8 file to v9 and keeps every live memory.

Fields

§version: u16

The file’s on-disk format version.

§

EmbedderMismatch

EMBED-ID-1: the embedder passed to crate::Mnemo::set_embedder isn’t the one this file’s vectors came from. The file records the identity of the first embedder attached to it; a different name, width or normalize flag is refused, because mixing two models’ vectors in one file silently breaks recall. Use the original embedder, or create a new store for the new model.

Since v0.15 the identity includes the query convention (crate::EmbedderIdentity::query_convention), and mnemo reembed moves a file to a new embedder.

Fields

§stored: Box<EmbedderIdentity>

The identity the file records (boxed since v0.15, which added query_convention, to keep the error small).

§given: Box<EmbedderIdentity>

The identity of the embedder that was passed.

Trait Implementations§

Source§

impl Debug for MnemoError

Source§

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

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

impl Display for MnemoError

Source§

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

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

impl Error for MnemoError

Source§

fn source(&self) -> Option<&(dyn Error + 'static)>

Returns the lower-level source of this error, if any. Read more
1.0.0 · Source§

fn description(&self) -> &str

👎Deprecated since 1.42.0:

use the Display impl or to_string()

1.0.0 · Source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0:

replaced by Error::source, which can support downcasting

Source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type-based access to context intended for error reports. Read more
Source§

impl From<Error> for MnemoError

Source§

fn from(source: Error) -> Self

Converts to this type from the input type.

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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