Struct DoltGraph

Source
pub struct DoltGraph {
    pub repo_path: PathBuf,
}
Expand description

Wrapper around a Dolt repository that stores graph data.

The DoltGraph type encapsulates a path to a Dolt repo and provides high‑level operations such as initializing the repo, committing changes, creating tables, and inserting nodes expressed as JSON objects.

§Architectural Rationale

Dolt offers a Git‑like version‑controlled SQL database, which aligns well with CHORUS’s need for an immutable, query‑able history of graph mutations. By wrapping Dolt commands in this struct we isolate the rest of the codebase from the command‑line interface, making the graph layer portable and easier to test.

Fields§

§repo_path: PathBuf

Filesystem path to the root of the Dolt repository.

Implementations§

Source§

impl DoltGraph

Source

pub fn init(path: &Path) -> Result<Self, GraphError>

Initialise (or open) a Dolt repository at the given path.

If the directory does not already contain a .dolt sub‑directory, the function runs dolt init to create a new repository. Errors from the underlying command are wrapped in GraphError::CommandFailed.

Source

pub fn commit(&self, message: &str) -> Result<(), GraphError>

Stage all changes and commit them with the provided message.

The method first runs dolt add -A to stage modifications, then dolt commit -m. Any failure in these steps propagates as a GraphError.

Source

pub fn create_table( &self, table_name: &str, schema: &str, ) -> Result<(), GraphError>

Create a SQL table within the Dolt repository.

schema should be a comma‑separated column definition list (e.g., "id INT PRIMARY KEY, name TEXT"). If the table already exists, the function treats it as a no‑op and returns Ok(()).

Source

pub fn insert_node(&self, table: &str, data: Value) -> Result<(), GraphError>

Insert a node represented by a JSON object into the specified table.

The JSON data must be an object where keys correspond to column names. Supported value types are strings, numbers, booleans, and null. Complex JSON structures are rejected because they cannot be directly mapped to SQL scalar columns.

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