### Handling File Metadata Operations with and_then Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html This example demonstrates chaining fallible file system operations using `and_then`. It attempts to get the metadata and then the modified time of a path. It handles potential errors like 'NotFound'. ```rust use std::{io::ErrorKind, path::Path}; // Note: on Windows "/" maps to "C:\\" let root_modified_time = Path::new("/").metadata().and_then(|md| md.modified()); assert!(root_modified_time.is_ok()); let should_fail = Path::new("/bad/path").metadata().and_then(|md| md.modified()); assert!(should_fail.is_err()); assert_eq!(should_fail.unwrap_err().kind(), ErrorKind::NotFound); ``` -------------------------------- ### Quick Start SparrowDB GraphDb Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/index.html Opens a SparrowDB database, performs a checkpoint, and optimizes the storage. Ensure the path exists and is accessible. ```rust use sparrowdb::GraphDb; let db = GraphDb::open(std::path::Path::new("/tmp/my.sparrow")).unwrap(); db.checkpoint().unwrap(); db.optimize().unwrap(); ``` -------------------------------- ### Get Database Path Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Retrieves the filesystem path of the SparrowDB database. ```rust pub fn path(&self) -> &Path ``` -------------------------------- ### Product of Results from Iterator Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html This example demonstrates how to compute the product of elements from an iterator where each element is a Result. If any element is an Err, the entire operation short-circuits and returns that Err. Otherwise, it returns the Ok value of the computed product. ```rust let nums = vec!["5", "10", "1", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert_eq!(total, Ok(100)); ``` ```rust let nums = vec!["5", "10", "one", "2"]; let total: Result = nums.iter().map(|w| w.parse::()).product(); assert!(total.is_err()); ``` -------------------------------- ### Into Ok Value (Never Panics) Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `into_ok` to get the contained `Ok` value. This method is guaranteed not to panic and can be used as a compile-time safeguard. ```rust fn only_good_news() -> Result { Ok("this is fine".into()) } let s: String = only_good_news().into_ok(); println!("{s}"); ``` -------------------------------- ### Get Database Statistics Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Retrieves a storage-size snapshot of the database. This is a pure read operation that does not acquire locks. Filesystem entries that cannot be read are silently skipped, so the reported values may be a lower bound. ```rust pub fn stats(&self) -> Result ``` -------------------------------- ### Summing Elements in an Iterator with Error Handling Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html This example demonstrates how to sum elements of an iterator where each element is a Result. If any element is an Err, the summation stops and that Err is returned. Otherwise, the sum of Ok values is returned. This is useful for processing collections where an error at any point should halt the operation. ```rust let f = |&x: &i32| if x < 0 { Err("Negative element found") } else { Ok(x) }; let v = vec![1, 2]; let res: Result = v.iter().map(f).sum(); assert_eq!(res, Ok(3)); let v = vec![1, -2]; let res: Result = v.iter().map(f).sum(); assert_eq!(res, Err("Negative element found")); ``` -------------------------------- ### open Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/fn.open.html Convenience wrapper — equivalent to `GraphDb::open`. ```APIDOC ## open ### Description Convenience wrapper — equivalent to `GraphDb::open`. ### Signature ```rust pub fn open(path: &Path) -> Result ``` ``` -------------------------------- ### Create a new BulkLoader Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkLoader.html Instantiates a new BulkLoader with specified database connection and options. Use this to begin loading data in bulk. ```rust pub fn new(db: &'a GraphDb, options: BulkOptions) -> Self ``` -------------------------------- ### Deref Pointable BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Dereferences a pointer to get an immutable reference to BulkOptions. ```rust unsafe fn deref<'a>(ptr: usize) -> &'a T ``` -------------------------------- ### Deref Mut Pointable BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Dereferences a pointer to get a mutable reference to BulkOptions. ```rust unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T ``` -------------------------------- ### Open a SparrowDB Database Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Opens or creates a SparrowDB database at the specified file system path. This is the primary way to obtain a GraphDb instance. ```rust pub fn open(path: &Path) -> Result ``` -------------------------------- ### Any Trait Implementation Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/export/struct.GraphDump.html Provides a method to get the TypeId of a type, useful for runtime type identification. ```rust fn type_id(&self) -> TypeId ``` -------------------------------- ### Initialize Pointable BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Initializes a pointer with the given initializer for BulkOptions. ```rust unsafe fn init(init: ::Init) -> usize ``` -------------------------------- ### Unwrap Error Value Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `unwrap_err` to get the contained `Err` value. Panics if the value is an `Ok`. ```rust let x: Result = Ok(2); x.unwrap_err(); // panics with `2` ``` ```rust let x: Result = Err("emergency failure"); assert_eq!(x.unwrap_err(), "emergency failure"); ``` -------------------------------- ### Default BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Provides the default configuration for BulkOptions. Uses a batch size of 10,000, a comma delimiter, and assumes a header row. ```rust fn default() -> Self ``` -------------------------------- ### Unwrap Ok Value Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `unwrap` to get the contained `Ok` value. Panics if the value is an `Err`. ```rust let x: Result = Ok(2); assert_eq!(x.unwrap(), 2); ``` -------------------------------- ### Get Registered Relationship Types Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Retrieves a sorted, deduplicated list of all relationship type names registered in the catalog. ```rust let rel_types = db.relationship_types()?; ``` -------------------------------- ### GraphDb::open Source: https://docs.rs/sparrowdb Opens or creates a SparrowDB database at the specified path. This is a convenience wrapper for database initialization. ```APIDOC ## GraphDb::open ### Description Opens or creates a SparrowDB database at the specified path. This is a convenience wrapper for database initialization. ### Signature ```rust fn open(path: &std::path::Path) -> Result ``` ### Parameters * **path** (`&std::path::Path`) - The file system path to the database directory. ### Returns A `Result` containing the `GraphDb` handle if successful, or an `Error` otherwise. ``` -------------------------------- ### into_ok Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Returns the contained Ok value, but never panics. ```APIDOC ## into_ok ### Description Returns the contained `Ok` value, but never panics. This method is known to never panic on the result types it is implemented for, making it a maintainability safeguard. ### Method `into_ok()` ### Parameters None ### Response - `T`: The contained `Ok` value. ### Constraints Requires `E` to implement `Into`. ``` -------------------------------- ### Begin a Write Transaction Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Opens a write transaction. This method uses try-lock semantics and returns an error immediately if another write transaction is active, rather than blocking. ```rust pub fn begin_write(&self) -> Result ``` -------------------------------- ### Into Err Value (Never Panics) Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `into_err` to get the contained `Err` value. This method is guaranteed not to panic and can be used as a compile-time safeguard. ```rust fn only_bad_news() -> Result { Err("Oops, it failed".into()) } let error: String = only_bad_news().into_err(); println!("{error}"); ``` -------------------------------- ### Open an Encrypted SparrowDB Database Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Opens or creates an encrypted SparrowDB database. A 32-byte key is required, and the same key must be used for subsequent opens. Incorrect keys will cause WAL replay to fail. ```rust pub fn open_encrypted(path: &Path, key: [u8; 32]) -> Result ``` -------------------------------- ### VZip Implementation Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/export/struct.GraphDump.html Provides functionality for zipping multiple lanes. ```APIDOC ### impl VZip for T where V: MultiLane, Source§ #### fn vzip(self) -> V Source§ ``` -------------------------------- ### Unsafely Unwrapping an Err Value Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `unwrap_err_unchecked` to get the contained `Err` value without checking if it's an `Ok`. Calling this on an `Ok` is undefined behavior. ```rust let x: Result = Err("emergency failure"); assert_eq!(unsafe { x.unwrap_err_unchecked() }, "emergency failure"); ``` -------------------------------- ### GraphDb::open Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Opens or creates a SparrowDB database at the specified path. ```APIDOC ## GraphDb::open ### Description Open (or create) a SparrowDB database at `path`. ### Method `open(path: &Path) -> Result` ### Parameters #### Path Parameters - **path** (`&Path`) - Required - The filesystem path where the database will be opened or created. ### Returns - `Result`: A `Result` containing the opened `GraphDb` instance or an error. ``` -------------------------------- ### Unsafely Unwrapping an Ok Value Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `unwrap_unchecked` to get the contained `Ok` value without checking if it's an `Err`. Calling this on an `Err` is undefined behavior. ```rust let x: Result = Ok(2); assert_eq!(unsafe { x.unwrap_unchecked() }, 2); ``` -------------------------------- ### Create Full-Text Index Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Creates or overwrites a named full-text index. This prepares the on-disk backing file for subsequent queries using `CALL db.index.fulltext.queryNodes`. ```rust db.create_fulltext_index("searchIndex")?; ``` -------------------------------- ### Providing a Default Value with unwrap_or Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `unwrap_or` to get the contained `Ok` value or a provided default if the `Result` is `Err`. Arguments to `unwrap_or` are eagerly evaluated. ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` -------------------------------- ### Unwrap or Default Value Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `unwrap_or_default` to get the contained `Ok` value or the default value if it's an `Err`. Requires the error type to implement `Default`. ```rust let good_year_from_input = "1909"; let bad_year_from_input = "190blarg"; let good_year = good_year_from_input.parse().unwrap_or_default(); let bad_year = bad_year_from_input.parse().unwrap_or_default(); assert_eq!(1909, good_year); assert_eq!(0, bad_year); ``` -------------------------------- ### Try Into BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Performs a fallible conversion from BulkOptions into another type. ```rust fn try_into(self) -> Result>::Error> ``` -------------------------------- ### Get Registered Node Labels Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Retrieves a list of all node label names currently registered in the catalog. Labels are automatically registered when a node with that label is first created. ```rust let labels = db.labels()?; ``` -------------------------------- ### Lazily Computing a Default Value with unwrap_or_else Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `unwrap_or_else` to get the contained `Ok` value or compute it from a closure if the `Result` is `Err`. This is useful when the default value is expensive to compute. ```rust fn count(x: &str) -> usize { x.len() } assert_eq!(Ok(2).unwrap_or_else(count), 2); assert_eq!(Err("foo").unwrap_or_else(count), 3); ``` -------------------------------- ### ok() Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Converts `self` into an `Option`, consuming `self`, and converting the error to `None`, if any. ```APIDOC ## pub fn ok(self) -> Option ### Description Converts `self` into an `Option`, consuming `self`, and converting the error to `None`, if any. ### Method `ok()` ### Request Example ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` ### Response Example ```rust // Returns Some(value) if Ok, None if Err ``` ``` -------------------------------- ### Expect Error Value with Panic Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `expect_err` to get the contained `Err` value. Panics if the value is an `Ok`, with a message including the provided string and the `Ok`'s content. ```rust let x: Result = Ok(10); x.expect_err("Testing expect_err"); // panics with `Testing expect_err: 10` ``` -------------------------------- ### GraphDb::begin_write Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Opens a write transaction with try-lock semantics. ```APIDOC ## GraphDb::begin_write ### Description Open a write transaction. Returns `Error::WriterBusy` immediately if another `WriteTx` is already active (try-lock semantics — does not block). ### Method `&self` ### Returns - `Result`: A `Result` containing the `WriteTx` instance or an error. ``` -------------------------------- ### BulkOptions Struct Definition Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Defines the configuration options for bulk loading. ```APIDOC ## Struct BulkOptions Configuration for `BulkLoader`. ### Fields * `batch_size: usize` Number of CSV rows processed per [`WriteTx`] commit. Larger values reduce commit overhead but increase peak memory usage. Default: `10_000`. * `delimiter: u8` CSV field delimiter byte. Default: `b','`. * `has_header: bool` Whether the CSV file has a header row. Default: `true`. ``` -------------------------------- ### Get Top Degree Nodes by Label Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Returns the top-`limit` nodes of a specified label, ordered by out-degree in descending order. This operation is efficient, utilizing a pre-computed `DegreeCache`. ```rust let top_nodes = db.top_degree_nodes("Person", 10)?; ``` -------------------------------- ### BulkLoader::new Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkLoader.html Creates a new BulkLoader instance, wrapping a GraphDb and configuring it with specified options for bulk operations. ```APIDOC ## BulkLoader::new ### Description Create a new `BulkLoader` wrapping `db` with the given `options`. ### Signature ```rust pub fn new(db: &'a GraphDb, options: BulkOptions) -> Self ``` ### Parameters * `db` (&'a GraphDb): A reference to the GraphDb instance to wrap. * `options` (BulkOptions): The configuration options for the bulk loader. ``` -------------------------------- ### Get or Create Label ID Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.WriteTx.html Looks up a label by name, creating it if it doesn't exist. This method is idempotent and returns the label ID. New labels are staged and written to disk on commit. ```rust pub fn get_or_create_label_id(&mut self, name: &str) -> Result ``` -------------------------------- ### Get Database Node and Edge Counts Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Retrieves the total number of nodes and edges in the database by summing high-water marks and delta-log record counts. These counts reflect committed storage state. ```rust let (node_count, edge_count) = db.db_counts()?; ``` -------------------------------- ### Define BulkOptions Struct Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Defines the configuration options for bulk loading operations. Customize batch size, delimiter, and header presence. ```rust pub struct BulkOptions { pub batch_size: usize, pub delimiter: u8, pub has_header: bool, } ``` -------------------------------- ### CloneToUninit Trait Implementation (Nightly) Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/export/struct.GraphDump.html An experimental nightly-only API for performing copy-assignment from self to an uninitialized memory location. ```rust unsafe fn clone_to_uninit(&self, dest: *mut u8) ``` -------------------------------- ### Pointable BulkOptions Init Type Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Specifies the initializer type for pointer operations on BulkOptions. ```rust type Init = T ``` -------------------------------- ### as_ref() Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Produces a new `Result`, containing a reference into the original, leaving the original in place. ```APIDOC ## pub const fn as_ref(&self) -> Result<&T, &E> ### Description Produces a new `Result`, containing a reference into the original, leaving the original in place. ### Method `as_ref()` ### Request Example ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` ### Response Example ```rust // Returns Ok(&value) if Ok, Err(&error) if Err ``` ``` -------------------------------- ### unwrap_or Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Returns the contained `Ok` value or a provided default. Arguments are eagerly evaluated. ```APIDOC ## pub fn unwrap_or(self, default: T) -> T ### Description Returns the contained `Ok` value or a provided default. Arguments passed to `unwrap_or` are eagerly evaluated; if you are passing the result of a function call, it is recommended to use `unwrap_or_else`, which is lazily evaluated. ### Examples ```rust let default = 2; let x: Result = Ok(9); assert_eq!(x.unwrap_or(default), 9); let x: Result = Err("error"); assert_eq!(x.unwrap_or(default), default); ``` ``` -------------------------------- ### try_into Method Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/export/struct.GraphDump.html Performs the conversion from one type to another, returning a Result. ```APIDOC #### fn try_into(self) -> Result>::Error> Performs the conversion. Source§ ``` -------------------------------- ### To Owned BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Creates owned data from borrowed data, usually by cloning. ```rust fn to_owned(&self) -> T ``` -------------------------------- ### GraphDb::open Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/index.html Opens a connection to the SparrowDB database. This is a convenience wrapper equivalent to `GraphDb::open`. ```APIDOC ## GraphDb::open ### Description Opens a connection to the SparrowDB database. ### Function Signature `pub fn open(path: &std::path::Path) -> Result` ### Parameters * **path** (`&std::path::Path`) - The path to the database file. ### Returns A `Result` containing the `GraphDb` handle on success, or an `Error` on failure. ``` -------------------------------- ### Convert Result to Option with Ok value Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use the `ok()` method to convert a `Result` into an `Option`. If the Result is `Ok`, it returns `Some(T)`; otherwise, it returns `None`. ```rust let x: Result = Ok(2); assert_eq!(x.ok(), Some(2)); let x: Result = Err("Nothing here"); assert_eq!(x.ok(), None); ``` -------------------------------- ### GraphDb::begin_write Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Initiates a write transaction. Returns immediately if another write transaction is active. ```APIDOC ## GraphDb::begin_write ### Description Opens a write transaction. This method uses try-lock semantics and returns `Error::WriterBusy` immediately if another `WriteTx` is already active, without blocking. ### Method `pub fn begin_write(&self) -> Result` ### Response #### Success Response - **WriteTx** - A write transaction handle. #### Errors - **Result** - Returns `Error::WriterBusy` if another write transaction is active, or another error if the transaction cannot be opened. ``` -------------------------------- ### Clone Into BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Uses borrowed data to replace owned data, usually by cloning. ```rust fn clone_into(&self, target: &mut T) ``` -------------------------------- ### impl PartialEq for Value Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/enum.Value.html Enables comparison of Value instances for equality. ```APIDOC ### impl PartialEq for Value #### fn eq(&self, other: &Value) -> bool Tests for `self` and `other` values to be equal, and is used by `==`. 1.0.0 · Source #### fn ne(&self, other: &Rhs) -> bool Tests for `!=`. The default implementation is almost always sufficient, and should not be overridden without very good reason. Source ``` -------------------------------- ### Same Trait Methods Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/enum.Value.html Methods associated with the `Same` trait. ```APIDOC ## type Output = T ### Description Should always be `Self`. ``` -------------------------------- ### Export Graph to DOT Format Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Exports the graph as a DOT (Graphviz) string. This can be used for visualization or saved to a .dot file for offline rendering. The output is correct regardless of whether the database has been checkpointed. ```rust let dot = db.export_dot().unwrap(); std::fs::write("graph.dot", &dot).unwrap(); // Then: dot -Tsvg graph.dot -o graph.svg ``` -------------------------------- ### Begin a Read-Only Transaction Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Opens a read-only snapshot transaction. The transaction will see all data committed at or before the time of the call. ```rust pub fn begin_read(&self) -> Result ``` -------------------------------- ### Convert &Result to Result<&T, &E> Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Use `as_ref()` to convert a reference to a `Result` into a `Result` of references. This allows inspecting the contents without consuming the original `Result`. ```rust let x: Result = Ok(2); assert_eq!(x.as_ref(), Ok(&2)); let x: Result = Err("Error"); assert_eq!(x.as_ref(), Err(&"Error")); ``` -------------------------------- ### Create Node with Properties Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.WriteTx.html Creates a new node with the given label and properties. The node is staged in memory and not persisted until commit. Dropping the transaction without committing discards the operation. ```rust pub fn create_node( &mut self, label_id: u32, props: &[(u32, Value)], ) -> Result ``` -------------------------------- ### Execute a Cypher Query (Chunked Pipeline) Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Executes a Cypher query using the chunked vectorized pipeline. This is identical to `execute` but enables `use_chunked_pipeline` for qualifying query shapes, which is preferred for benchmarking and measuring the Phase 2+ pipeline. ```rust pub fn execute_chunked(&self, cypher: &str) -> Result ``` -------------------------------- ### WithSubscriber Implementation Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/export/struct.GraphDump.html Allows attaching subscribers to a type. ```APIDOC ### impl WithSubscriber for T Source§ #### fn with_subscriber(self, subscriber: S) -> WithDispatch where S: Into, Attaches the provided `Subscriber` to this type, returning a `WithDispatch` wrapper. Read more Source§ #### fn with_current_subscriber(self) -> WithDispatch Attaches the current default `Subscriber` to this type, returning a `WithDispatch` wrapper. Read more Source§ ``` -------------------------------- ### Pointable Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.NodeId.html Defines methods for pointer-like operations on NodeId, including initialization, dereferencing, and dropping. ```APIDOC ## const ALIGN: usize ### Description The alignment requirement for pointers. ### Type `usize` ``` ```APIDOC ## type Init = T ### Description The type used for initializers. ### Type `T` ``` ```APIDOC ## unsafe fn init(init: ::Init) -> usize ### Description Initializes a new object with the given initializer and returns its pointer address. ### Method `init` ### Parameters - **init** (::Init) - The initializer for the object. ``` ```APIDOC ## unsafe fn deref<'a>(ptr: usize) -> &'a T ### Description Dereferences the given pointer to provide an immutable reference to the object. ### Method `deref` ### Parameters - **ptr** (usize) - The pointer address to dereference. ### Returns An immutable reference `&'a T` to the object. ``` ```APIDOC ## unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T ### Description Mutably dereferences the given pointer to provide a mutable reference to the object. ### Method `deref_mut` ### Parameters - **ptr** (usize) - The pointer address to dereference. ### Returns A mutable reference `&'a mut T` to the object. ``` ```APIDOC ## unsafe fn drop(ptr: usize) ### Description Drops the object pointed to by the given pointer, releasing its resources. ### Method `drop` ### Parameters - **ptr** (usize) - The pointer address of the object to drop. ``` -------------------------------- ### Implement Min for NodeId Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.NodeId.html Provides the `min` method for finding the minimum of two NodeIds. ```rust fn min(self, other: Self) -> Self where Self: Sized, ``` -------------------------------- ### TryInto Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.NodeId.html Enables fallible conversion from NodeId into another type U. ```APIDOC ## type Error = >::Error ### Description The type returned in the event of a conversion error. ### Type `>::Error` ``` ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the conversion from NodeId into type U. This conversion is fallible. ### Method `try_into` ### Returns A `Result` containing the converted type U on success, or an error if the conversion fails. ``` -------------------------------- ### Pointable BulkOptions Alignment Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Defines the alignment for pointer operations on BulkOptions. ```rust const ALIGN: usize ``` -------------------------------- ### Execute Multiple Cypher Queries in a Batch Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Executes a slice of Cypher queries as a single atomic batch. This is optimized for bulk data loading, ensuring atomicity and a single WAL fsync. Note that parameters are not supported; use `execute_with_params` for parameterized queries. ```rust use sparrowdb::GraphDb; let db = GraphDb::open(std::path::Path::new("/tmp/batch.sparrow")).unwrap(); let queries: Vec<&str> = (0..100) .map(|i| Box::leak(format!("CREATE (n:Person {{id: {{i}}}})", i = i).into_boxed_str()) as &str) .collect(); let results = db.execute_batch(&queries).unwrap(); assert_eq!(results.len(), 100); ``` -------------------------------- ### try_into Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/export/struct.NodeDump.html Performs a conversion from the current type to another type `U`. ```APIDOC ## fn try_into(self) -> Result>::Error> ### Description Performs the conversion. ### Method `try_into` ``` -------------------------------- ### Create Label Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.WriteTx.html Creates a new label in the schema catalog. The label is staged in memory and only written to disk on commit. Dropping the transaction without committing discards the label. ```rust pub fn create_label(&mut self, name: &str) -> Result ``` -------------------------------- ### From> for Result Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Converts an `Either` into a `Result`, mapping `Right` to `Ok` and `Left` to `Err`. ```APIDOC ## fn from(val: Either) -> Result ### Description Convert from `Either` to `Result` with `Right => Ok` and `Left => Err`. ### Method `from` ### Parameters - **val** (Either) - Description: The Either value to convert. ``` -------------------------------- ### Clone From BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Performs copy-assignment from a source BulkOptions value. ```rust fn clone_from(&mut self, source: &Self) ``` -------------------------------- ### Execute Cypher Queries in Atomic Batch Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Executes multiple Cypher queries as a single atomic batch. This is optimized for bulk data loading, offering a single WAL fsync for improved performance. Only write statements are accepted, though read-only queries are permitted and their results returned. ```rust use sparrowdb::GraphDb; let db = GraphDb::open(std::path::Path::new("/tmp/batch.sparrow")).unwrap(); let queries: Vec<&str> = (0..100) .map(|i| Box::leak(format!("CREATE (n:Person {{id: {i}}})", i = i).into_boxed_str()) as &str) .collect(); let results = db.execute_batch(&queries).unwrap(); assert_eq!(results.len(), 100); ``` -------------------------------- ### TryFrom Trait Methods Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/enum.Value.html Methods for attempting conversions that may fail. ```APIDOC ## type Error = Infallible ### Description The type returned in the event of a conversion error. ## fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion from type `U` to type `T`. ### Parameters - **value** (U) - Required - The value to convert. ### Returns - **Result>::Error>** - A `Result` containing the converted value or an error. ``` -------------------------------- ### impl TryInto for T Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.WriteTx.html Provides functionality to attempt conversion from one type to another, returning a Result. ```APIDOC ### impl TryInto for T where U: TryFrom, #### type Error = >::Error ### Description The type returned in the event of a conversion error. #### fn try_into(self) -> Result>::Error> ### Description Performs the conversion from type T to type U. ### Parameters #### Path Parameters - **self** (T) - Required - The value to convert. ``` -------------------------------- ### Migrate WAL Segments in Rust Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/fn.migrate_wal.html Call this function on a database path before opening it with GraphDb::open. The database must not be open by any other process. This migration is idempotent and safe to run on databases already at v2. ```rust use std::path::Path; let result = sparrowdb::migrate_wal(Path::new("/path/to/my.sparrow")).unwrap(); println!("Converted {} segments", result.segments_converted); ``` -------------------------------- ### snapshot Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.ReadTx.html Returns the snapshot TxnId this reader is pinned to. ```APIDOC ## snapshot ### Description Return the snapshot `TxnId` this reader is pinned to. ### Method `pub fn snapshot(&self) -> TxnId` ### Parameters None ### Response #### Success Response (TxnId) - `TxnId`: The transaction ID representing the snapshot. #### Response Example ```json 12345 ``` ``` -------------------------------- ### unwrap Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Returns the contained Ok value or panics if the value is an Err. ```APIDOC ## unwrap ### Description Returns the contained `Ok` value or panics if the value is an `Err`, with a panic message provided by the `Err`’s value. ### Method `unwrap()` ### Parameters None ### Response - `T`: The contained `Ok` value if successful. ### Panics Panics if the value is an `Err`. ``` -------------------------------- ### Try Trait for Result (Experimental) Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Experimental nightly-only API for the Try trait, enabling more advanced control flow with the `?` operator. ```APIDOC ## impl Try for Result ### Description This is a nightly-only experimental API that implements the `Try` trait for `Result`. This trait provides advanced control flow capabilities, particularly with the `?` operator, allowing for more nuanced handling of success and failure cases. ### Type Aliases - `Output = T`: The type of the value produced by `?` when not short-circuiting. - `Residual = Result`: The type of the value passed to `FromResidual::from_residual` as part of `?` when short-circuiting. ### Methods - `from_output(output: as Try>::Output) -> Result`: Constructs the `Result` type from its `Output` type. - `branch(self) -> ControlFlow< as Try>::Residual, as Try>::Output>`: Used in the `?` operator to determine whether to continue or break the control flow based on the `Result`'s value. ``` -------------------------------- ### Instrument BulkOptions with Span Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Instruments the BulkOptions value with a provided Span. ```rust fn instrument(self, span: Span) -> Instrumented ``` -------------------------------- ### execute_with_params Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Executes a Cypher query with runtime parameter bindings. Parameters are provided as a HashMap and can be referenced in the query using $name expressions. ```APIDOC ## execute_with_params ### Description Executes a Cypher query with runtime parameter bindings. Parameters are provided as a HashMap and can be referenced in the query using $name expressions. ### Method `GraphDb::execute_with_params` ### Parameters - `cypher`: `&str` - The Cypher query string to execute. - `params`: `HashMap` - A map of parameter names to their values. ### Response - `Result`: A `QueryResult` if the query executes successfully. ### Example ```rust use sparrowdb::GraphDb; use sparrowdb_execution::Value; use std::collections::HashMap; let db = GraphDb::open(std::path::Path::new("/tmp/my.sparrow")).unwrap(); let mut params = HashMap::new(); params.insert("names".into(), Value::List(vec![ Value::String("Alice".into()), Value::String("Bob".into()), ])); let result = db.execute_with_params("UNWIND $names AS name RETURN name", params).unwrap(); ``` ``` -------------------------------- ### impl TryFrom for T Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.WriteTx.html Provides functionality to attempt conversion from one type to another, returning a Result. ```APIDOC ### impl TryFrom for T where U: Into, #### type Error = Infallible ### Description The type returned in the event of a conversion error. #### fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion from type U to type T. ### Parameters #### Path Parameters - **value** (U) - Required - The value to convert. ``` -------------------------------- ### GraphDb::begin_read Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Initiates a read-only transaction, providing a snapshot of the database at the time of the call. ```APIDOC ## GraphDb::begin_read ### Description Opens a read-only snapshot transaction. The returned `ReadTx` reflects data committed at or before the current `txn_id` when the call is made. ### Method `pub fn begin_read(&self) -> Result` ### Response #### Success Response - **ReadTx** - A read-only transaction handle. #### Errors - **Result** - Returns an error if a read transaction cannot be opened. ``` -------------------------------- ### query Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.ReadTx.html Executes a read-only Cypher query against the pinned snapshot. The query sees exactly the committed state at the moment `begin_read` was called. Mutation statements are rejected. ```APIDOC ## query ### Description Execute a read-only Cypher query against the pinned snapshot. Snapshot isolation: The query sees exactly the committed state at the moment `begin_read` was called. Any writes committed after that point — even fully committed ones — are invisible until a new `ReadTx` is opened. Concurrency: Multiple `ReadTx` handles may run `query` concurrently. No write lock is acquired; only the shared read-paths of the catalog, CSR, and property-index caches are accessed. Mutation statements rejected: Passing a mutation statement (`CREATE`, `MERGE`, `MATCH … SET`, `MATCH … DELETE`, `CHECKPOINT`, `OPTIMIZE`, etc.) returns [`Error::ReadOnly`]. Use `GraphDb::execute` for mutations. ### Method `pub fn query(&self, cypher: &str) -> Result` ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```rust use sparrowdb::GraphDb; let db = GraphDb::open(std::path::Path::new("/tmp/g.sparrow")).unwrap(); let tx = db.begin_read().unwrap(); let result = tx.query("MATCH (n:Person) RETURN n.name").unwrap(); println!("{} rows", result.rows.len()); ``` ### Response #### Success Response (QueryResult) - `QueryResult`: Contains the results of the Cypher query. #### Response Example ```json { "rows": [ ["Alice"], ["Bob"] ], "columns": ["n.name"] } ``` ERROR HANDLING: - Returns `Result` which can contain `Error::ReadOnly` for mutation statements or other errors on failure. ``` -------------------------------- ### Pointable Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.EdgeId.html Defines operations for pointer manipulation, including alignment, initialization, dereferencing, and dropping. ```APIDOC ## const ALIGN: usize ### Description The alignment of pointer. ``` ```APIDOC ## type Init = T ### Description The type for initializers. ``` ```APIDOC ## unsafe fn init(init: ::Init) -> usize ### Description Initializes a with the given initializer. ``` ```APIDOC ## unsafe fn deref<'a>(ptr: usize) -> &'a T ### Description Dereferences the given pointer. ``` ```APIDOC ## unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T ### Description Mutably dereferences the given pointer. ``` ```APIDOC ## unsafe fn drop(ptr: usize) ### Description Drops the object pointed to by the given pointer. ``` -------------------------------- ### FromResidual> for Result Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Constructs a `Result` from a `Yeet` residual, where `F` can be created from `E`. ```APIDOC ## fn from_residual(_: Yeet) -> Result ### Description Constructs the type from a compatible `Residual` type. ### Method `from_residual` ### Parameters - **_** (Yeet) - Description: The residual to convert from. ``` -------------------------------- ### as_mut() Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Converts from `&mut Result` to `Result<&mut T, &mut E>`. ```APIDOC ## pub const fn as_mut(&mut self) -> Result<&mut T, &mut E> ### Description Converts from `&mut Result` to `Result<&mut T, &mut E>`. ### Method `as_mut()` ### Request Example ```rust fn mutate(r: &mut Result) { match r.as_mut() { Ok(v) => *v = 42, Err(e) => *e = 0, } } let mut x: Result = Ok(2); mutate(&mut x); assert_eq!(x.unwrap(), 42); let mut x: Result = Err(13); mutate(&mut x); assert_eq!(x.unwrap_err(), 0); ``` ### Response Example ```rust // Returns Ok(&mut value) if Ok, Err(&mut error) if Err ``` ``` -------------------------------- ### GraphDb::checkpoint Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/index.html Creates a checkpoint of the current database state. ```APIDOC ## GraphDb::checkpoint ### Description Creates a checkpoint of the current database state. ### Function Signature `pub fn checkpoint(&self) -> Result<()>` ### Returns A `Result` indicating success or failure. ``` -------------------------------- ### unwrap_or_default Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Returns the contained Ok value or a default value if the Result is Err. ```APIDOC ## unwrap_or_default ### Description Consumes the `self` argument. If `Ok`, returns the contained value. If `Err`, returns the default value for the type `T`. ### Method `unwrap_or_default()` ### Parameters None ### Response - `T`: The contained `Ok` value or the default value if `Err`. ### Constraints Requires `T` to implement the `Default` trait. ``` -------------------------------- ### impl Result::is_ok_and Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Returns `true` if the result is `Ok` and the value inside of it matches a predicate. ```APIDOC ## impl Result ### is_ok_and Returns `true` if the result is `Ok` and the value inside of it matches a predicate. #### Examples ```rust let x: Result = Ok(2); assert_eq!(x.is_ok_and(|x| x > 1), true); let x: Result = Ok(0); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Err("hey"); assert_eq!(x.is_ok_and(|x| x > 1), false); let x: Result = Ok("ownership".to_string()); assert_eq!(x.as_ref().is_ok_and(|x| x.len() > 1), true); println!("still alive {:?}", x); ``` ``` -------------------------------- ### Try Into Error for BulkOptions Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/struct.BulkOptions.html Defines the error type for TryInto conversions. ```rust type Error = >::Error ``` -------------------------------- ### Export Graph as DOT String Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Exports the entire graph structure as a DOT (Graphviz) formatted string, suitable for visualization. This method queries all nodes and reads edges directly from storage. ```rust let dot_string = db.export_dot()?; ``` -------------------------------- ### Load Nodes and Edges with BulkLoader Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/bulk/index.html Use BulkLoader to efficiently load nodes and edges from CSV files into a GraphDb. Ensure the GraphDb is opened and BulkOptions are configured. ```rust use std::path::Path; use sparrowdb::{GraphDb, bulk::{BulkLoader, BulkOptions}}; let db = GraphDb::open(Path::new("/tmp/my.sparrow")).unwrap(); let loader = BulkLoader::new(&db, BulkOptions::default()); let n = loader.load_nodes(Path::new("nodes.csv"), "Person").unwrap(); let e = loader.load_edges(Path::new("edges.csv"), "KNOWS", "Person", "Person").unwrap(); eprintln!("loaded {n} nodes, {e} edges"); ``` -------------------------------- ### Implement PartialEq for NodeId Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.NodeId.html Provides the `eq` method for testing equality between two NodeIds. ```rust fn eq(&self, other: &NodeId) -> bool ``` -------------------------------- ### TryFrom Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.NodeId.html Enables fallible conversion from another type U into NodeId. ```APIDOC ## type Error = Infallible ### Description The type returned in the event of a conversion error. This is `Infallible`, meaning conversion should not fail if `U: Into`. ### Type `Infallible` ``` ```APIDOC ## fn try_from(value: U) -> Result>::Error> ### Description Performs the conversion from type U to NodeId. This conversion is fallible. ### Method `try_from` ### Parameters - **value** (U) - The value of type U to convert. ### Returns A `Result` containing the converted NodeId on success, or an error if the conversion fails. ``` -------------------------------- ### unwrap Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.Result.html Returns the contained `Ok` value, consuming the `self` value. Panics if the value is an `Err`. ```APIDOC ## unwrap ### Description Returns the contained `Ok` value, consuming the `self` value. Panics if the value is an `Err`. ### Method `unwrap(self) -> T` where E: Debug ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example None ### Response #### Success Response (200) None #### Response Example None ``` -------------------------------- ### Clone GraphDb Instance Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Returns a duplicate of the `GraphDb` value. This allows for creating independent copies of the graph database. ```rust fn clone(&self) -> GraphDb ``` -------------------------------- ### Execute Parameterized Cypher Query Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.GraphDb.html Executes a Cypher query with runtime parameter bindings. Parameters are supplied as a HashMap and accessed within the query using $name expressions. ```rust use sparrowdb::GraphDb; use sparrowdb_execution::Value; use std::collections::HashMap; let db = GraphDb::open(std::path::Path::new("/tmp/my.sparrow")).unwrap(); let mut params = HashMap::new(); params.insert("names".into(), Value::List(vec![ Value::String("Alice".into()), Value::String("Bob".into()), ])); let result = db.execute_with_params("UNWIND $names AS name RETURN name", params).unwrap(); ``` -------------------------------- ### TryInto for T Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.DbStats.html Provides a way to attempt conversion from type T into type U, returning a Result. ```APIDOC ## impl TryInto for T where U: TryFrom ### type Error = >::Error The type returned in the event of a conversion error. ### fn try_into(self) -> Result>::Error> Performs the conversion. ``` -------------------------------- ### Same Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.EdgeId.html A marker trait indicating that the `Output` type is the same as `Self`. ```APIDOC ## type Output = T ### Description Should always be `Self` ``` -------------------------------- ### create_label Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/struct.WriteTx.html Creates a new label in the schema catalog. The label is staged and written to disk only on commit. ```APIDOC ## pub fn create_label ### Description Create a label in the schema catalog. The label is staged in memory and only written to the catalog file when `commit` is called. Dropping the transaction without committing discards the label — no ghost entries are left on disk (closes #305). Returns `Err(AlreadyExists)` if a label with that name already exists. ### Method `&mut self` ### Parameters - `name` (&str) - The name of the label to create. ### Returns - `Result` - The ID of the newly created label, or an error. ``` -------------------------------- ### export Source: https://docs.rs/sparrowdb/0.1.16/sparrowdb/type.SparrowDB.html Exports the entire graph data structure. ```APIDOC ## export ### Description Exports the entire graph data structure. ### Method `pub fn export(&self) -> Result` ```