Skip to main content

Crate nb_api

Crate nb_api 

Source
Expand description

Typed Rust interface to the nb note-taking CLI.

Handles notebook qualification, escaping, and output parsing. Wraps the nb CLI as a subprocess, providing async methods for all note-taking operations.

§Concurrency (0.3.0)

Notebook-scoped reads and Transaction::commit are serialized by a process-shared, in-process gate registry keyed by the realpath of the notebook Git common directory. Independently constructed NbClient values that resolve to the same repository share one gate. Cross-process index.lock wait is deferred.

Re-exports§

pub use fingerprint::Fingerprint;
pub use fingerprint::fingerprint as compute_fingerprint;
pub use parser::BodyFragments;
pub use parser::DocumentKind;
pub use parser::NoteDocument;
pub use parser::ParseContext;
pub use parser::SUPPORTED_DOCUMENT_EXTENSIONS;
pub use parser::TagsIter;
pub use parser::TagsStrIter;
pub use parser::TodoState;
pub use parser::parse;

Modules§

fingerprint
Fingerprint scheme for NoteDocument.
parser
Structural parser for nb notes, todos, and bookmarks.

Structs§

BodyFragment
One body fragment exposed by structured show.
ByteString
Arbitrary file bytes on the wire as standard base64.
CommitOutcome
Structured result of crate::Transaction::commit.
Config
Configuration for constructing an NbClient.
IoError
Serializable snapshot of a std::io::Error chain.
LineAnchor
Versioned body-line authenticity token: b3l1:<32 lowercase hex>.
LineRef
Number + anchor reference to a body line.
NbClient
Client for invoking nb commands.
NoteLine
One enumerated body line.
NoteLineHit
One search hit within a body line.
OpOutcome
Outcome of one plan op after a successful commit.
SearchNoteLines
Result of search_note_lines.
ShowNote
Structured show_note result.
ShowNoteLines
Windowed body-line listing.
Transaction
In-memory plan bound to one notebook. Drop discards; no begin/rollback.

Enums§

BoundaryAt
Virtual body boundaries (^ / $).
IoErrorKind
Discriminator for the std::io::ErrorKind taxonomy, lifted into a serializable form. Marked #[non_exhaustive] so future versions can add new kinds without breaking downstream match arms that include a default branch.
LineEdit
One line-oriented edit in an edit_note_lines batch.
LinePosition
Insert position relative to a line or body boundary.
LineTerminator
Line terminator as stored in the body.
NbError
Errors raised by nb-api operations.
NoteTarget
Address an existing note by selector or notebook-relative path.
Occurrence
Substring occurrence selector.
ParseErrorKind
Narrow refusal contract for the structural parser.
SearchMode
Matching mode for nb search query terms.
TaskStatus
Status filter for nb tasks.

Functions§

derive_git_notebook_name
Derive the notebook name from the current Git repository.
git_rev_parse
Run git rev-parse with the given arguments and return the output as a path.
leaked_git_names
Returns the names of every environment variable in the current process whose name starts with GIT_. Exposed so other call sites (a future std::process::Command variant in git_env, or any caller that wants the list without the scrub) share one enumeration policy.
scrub_git_env
Removes every environment variable whose name starts with GIT_ from the given tokio Command’s environment. The spawned process inherits every other variable from the parent (PATH, HOME, LANG, …), just not the ones that redirect Git’s view of the repository.
scrub_git_env_std
Synchronous-Command variant of scrub_git_env. nb-api uses tokio::process::Command for every nb invocation, but git_rev_parse (the only direct git spawn) uses std::process::Command. Both spawn sites must be scrubbed; if a future helper spawns git synchronously, use this overload.