gleamunison/codebase
Types
pub type InsertError {
HashMismatch(
hash_expected: identity.Hash,
hash_got: identity.Hash,
)
DuplicateDef(
existing: identity.DefinitionRef,
incoming: identity.DefinitionRef,
)
StorageFailure(storage.StorageError)
}
Constructors
-
HashMismatch( hash_expected: identity.Hash, hash_got: identity.Hash, ) -
DuplicateDef( existing: identity.DefinitionRef, incoming: identity.DefinitionRef, ) -
StorageFailure(storage.StorageError)
pub type ReadError {
NotFound(identity.DefinitionRef)
StoreFailure(storage.StorageError)
Corrupt(ref: identity.DefinitionRef, reason: String)
DecodeFailed(ref: identity.DefinitionRef, reason: String)
}
Constructors
-
NotFound(identity.DefinitionRef) -
StoreFailure(storage.StorageError) -
Corrupt(ref: identity.DefinitionRef, reason: String) -
DecodeFailed(ref: identity.DefinitionRef, reason: String)
Values
pub fn describe_insert_error(error: InsertError) -> String
The one place an InsertError becomes a user sentence. Rendering belongs here, with the type, rather than at each call site — inspect output is a debug rendering and must never reach a user.
pub fn describe_read_error(error: ReadError) -> String
The one place a ReadError becomes a user sentence. Same rule as describe_insert_error: rendering belongs with the type, and inspect output must never reach a user. NotFound carries no sentence here — callers with a “missing” vocabulary of their own name it there.
pub fn get(
codebase: Codebase,
ref: identity.DefinitionRef,
) -> Result(ast.Definition, ReadError)
The read half of the store. Identity is the ref, so a stored payload is re-verified before it is decoded: a store that disagrees with its own keys must not be able to hand a different definition to the loader.
pub fn get_adapter(codebase: Codebase) -> storage.StorageAdapter
pub fn hash_of_definition(def: ast.Definition) -> identity.Hash
pub fn insert_raw_checked(
codebase: Codebase,
ref: identity.DefinitionRef,
bytes: BitArray,
) -> Result(Codebase, InsertError)
pub fn with_adapter(adapter: storage.StorageAdapter) -> Codebase
A codebase over a caller-chosen adapter (dets for persistence, mnesia for replication). Sync and CLI paths need real storage, not inmemory.