pub struct Kmap { /* private fields */ }Expand description
A serialized handle to one Kweb DB Core SQLite database and artifact directory.
The caller must serialize access and must not expect multi-call atomicity.
Implementations§
Source§impl Kmap
impl Kmap
Sourcepub fn open(path: impl AsRef<Path>) -> Result<Self, Error>
pub fn open(path: impl AsRef<Path>) -> Result<Self, Error>
Opens or creates a database and derives its sibling artifact directory.
kweb.sqlite3 derives kweb-provenance-artifacts. This enables foreign
keys, WAL journaling, a five-second busy timeout, and initializes the
current schema when opening a new database.
Sourcepub fn open_with_artifacts(
path: impl AsRef<Path>,
artifact_path: impl AsRef<Path>,
) -> Result<Self, Error>
pub fn open_with_artifacts( path: impl AsRef<Path>, artifact_path: impl AsRef<Path>, ) -> Result<Self, Error>
Opens or creates a database with an explicit artifact-directory path.
Sourcepub fn artifact_path(&self) -> &Path
pub fn artifact_path(&self) -> &Path
Returns the configured artifact-directory path.
Sourcepub fn create_provenance(
&mut self,
idempotency_id: IdempotencyId,
input: NewProvenance,
) -> Result<ProvenanceId, Error>
pub fn create_provenance( &mut self, idempotency_id: IdempotencyId, input: NewProvenance, ) -> Result<ProvenanceId, Error>
Creates immutable provenance without explicit attached artifacts.
Main data larger than 256 KiB is stored externally. An exact replay of
idempotency_id and input returns the original identifier without a
second write.
Sourcepub fn create_provenance_with_storage(
&mut self,
idempotency_id: IdempotencyId,
input: NewProvenance,
storage: ProvenanceStorage,
) -> Result<ProvenanceId, Error>
pub fn create_provenance_with_storage( &mut self, idempotency_id: IdempotencyId, input: NewProvenance, storage: ProvenanceStorage, ) -> Result<ProvenanceId, Error>
Creates immutable provenance with ordered attached artifacts.
storage.data_filename names the main data if it crosses the 256 KiB
external-storage threshold. An exact replay returns the original ID.
Sourcepub fn create_node(
&mut self,
idempotency_id: IdempotencyId,
input: CreateNode,
) -> Result<Node, Error>
pub fn create_node( &mut self, idempotency_id: IdempotencyId, input: CreateNode, ) -> Result<Node, Error>
Creates a knowledge node, its first history entry, and both connections.
All referenced provenance, owner, and connection nodes must exist. An exact idempotent replay adds no history and returns the current node.
Sourcepub fn update_node(
&mut self,
idempotency_id: IdempotencyId,
id: NodeId,
input: UpdateNode,
) -> Result<Node, Error>
pub fn update_node( &mut self, idempotency_id: IdempotencyId, id: NodeId, input: UpdateNode, ) -> Result<Node, Error>
Replaces a knowledge node and appends one provenance-history entry.
Both connection arrays are complete replacements. An exact idempotent replay appends no history and returns the current node.
Sourcepub fn get_node(&self, id: NodeId) -> Result<Node, Error>
pub fn get_node(&self, id: NodeId) -> Result<Node, Error>
Returns a complete knowledge node by durable identifier.
Sourcepub fn get_provenance(&self, id: ProvenanceId) -> Result<Provenance, Error>
pub fn get_provenance(&self, id: ProvenanceId) -> Result<Provenance, Error>
Returns immutable provenance and ordered artifact metadata.
Externally stored main UTF-8 data is read transparently. Explicit attached artifact bytes are not loaded into the result.
Sourcepub fn get_node_history(&self, id: NodeId) -> Result<Vec<ProvenanceId>, Error>
pub fn get_node_history(&self, id: NodeId) -> Result<Vec<ProvenanceId>, Error>
Returns the node’s complete provenance history, newest first.
The traversal detects a corrupt cycle and returns Error::Conflict.