mirror of
https://github.com/ModernRelay/omnigraph.git
synced 2026-06-12 01:45:14 +02:00
refactor(loader): load_jsonl helpers take &Omnigraph and document their role
The free helpers needlessly demanded &mut Omnigraph (every load API takes &self) and read as leftovers. Rather than rewriting their ~200 call sites across the test suites — which would have to re-derive the active-branch resolution at each site — keep the one convenience and make it honest: borrow immutably (&mut callers coerce, no churn) and document it as the active-branch shorthand over Omnigraph::load. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
e676c151bb
commit
c236a4c2df
1 changed files with 7 additions and 4 deletions
|
|
@ -65,15 +65,18 @@ pub enum LoadMode {
|
|||
Merge,
|
||||
}
|
||||
|
||||
/// Load JSONL data into an Omnigraph database.
|
||||
pub async fn load_jsonl(db: &mut Omnigraph, data: &str, mode: LoadMode) -> Result<LoadResult> {
|
||||
/// Convenience: load JSONL data onto the database handle's *active branch*
|
||||
/// (`main` when unbound). Equivalent to `db.load(active_branch, data, mode)`;
|
||||
/// use `Omnigraph::load`/`load_as` directly when targeting an explicit branch
|
||||
/// or when fork-from-base semantics are needed.
|
||||
pub async fn load_jsonl(db: &Omnigraph, data: &str, mode: LoadMode) -> Result<LoadResult> {
|
||||
let current_branch = db.active_branch().await;
|
||||
let branch = current_branch.as_deref().unwrap_or("main");
|
||||
db.load(branch, data, mode).await
|
||||
}
|
||||
|
||||
/// Load JSONL data from a file path.
|
||||
pub async fn load_jsonl_file(db: &mut Omnigraph, path: &str, mode: LoadMode) -> Result<LoadResult> {
|
||||
/// Convenience: like [`load_jsonl`] but reading from a file path.
|
||||
pub async fn load_jsonl_file(db: &Omnigraph, path: &str, mode: LoadMode) -> Result<LoadResult> {
|
||||
let current_branch = db.active_branch().await;
|
||||
let branch = current_branch.as_deref().unwrap_or("main");
|
||||
db.load_file(branch, path, mode).await
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue