[][src]Trait starling::traits::Database

pub trait Database<ArrayType> where
    ArrayType: Array
{ type NodeType; type EntryType; fn open(path: &PathBuf) -> Result<Self, Exception>
    where
        Self: Sized
;
fn get_node(
        &self,
        key: ArrayType
    ) -> Result<Option<Self::NodeType>, Exception>;
fn insert(
        &mut self,
        key: ArrayType,
        node: Self::NodeType
    ) -> Result<(), Exception>;
fn remove(&mut self, key: &ArrayType) -> Result<(), Exception>;
fn batch_write(&mut self) -> Result<(), Exception>; }

This trait defines the required interface for connecting a storage mechanism to the MerkleBIT.

Associated Types

type NodeType

The type of node to insert into the database.

type EntryType

The type of entry for insertion. Primarily for convenience and tracking what goes into the database.

Loading content...

Required methods

fn open(path: &PathBuf) -> Result<Self, Exception> where
    Self: Sized

Opens an existing Database.

Errors

Exception generated if the open does not succeed.

fn get_node(&self, key: ArrayType) -> Result<Option<Self::NodeType>, Exception>

Gets a value from the database based on the given key.

Errors

Exception generated if the get_node does not succeed.

fn insert(
    &mut self,
    key: ArrayType,
    node: Self::NodeType
) -> Result<(), Exception>

Queues a key and its associated value for insertion to the database.

Errors

Exception generated if the insert does not succeed.

fn remove(&mut self, key: &ArrayType) -> Result<(), Exception>

Removes a key and its associated value from the database.

Errors

Exception generated if the remove does not succeed.

fn batch_write(&mut self) -> Result<(), Exception>

Confirms previous inserts and writes the changes to the database.

Errors

Exception generated if the batch_write does not succeed.

Loading content...

Implementors

impl<ArrayType> Database<ArrayType> for HashDB<ArrayType> where
    ArrayType: Array
[src]

type NodeType = TreeNode<ArrayType>

type EntryType = ([u8; 32], Vec<u8>)

Loading content...