[][src]Struct mycelium_lib::Mycelium

pub struct Mycelium {
    pub config: Config,
    // some fields omitted
}

Mycelium

Primary method to embed database into applications is through this struct.

TCP, UDP, or calling functions implemented on Mycelium in this library to interact with the database.

TCP (localhost) is not required. UDP server should be started for distributed behavior, but is not required if that behavior is not desired.

Fields

config: Config

Methods

impl Mycelium[src]

pub fn init_db(config: Config) -> Arc<Mycelium>[src]

Init_db

Initialize a new instance of Mycelium

use mycelium_lib::prelude::*;

let config = Config::default()
 .with_data_directory("./");

let db = Mycelium::init_db(config);

pub fn config(&self) -> Config[src]

pub fn execute_command(&self, cmd: Command) -> Result<Result, Box<dyn Error>>[src]

Embedded option

use mycelium_command::prelude::*;
use mycelium_lib::{ prelude::*, Mycelium };
use mycelium_index::prelude::Config;

let config = Config::fetch_or_default(&std::env::current_exe().expect("a path"))
    .expect("failed to get a default config");
let db = Mycelium::init_db(config.0);
let cmd = Command::new()
    .with_action(Action::Insert(b"Mastiff, Pyranese, Shepard...
        I do not know my dogs well.".to_vec()))
    .with_tag("dog")
    .with_what(What::Index("working".to_string()));

match db.execute_command(cmd) {
    Ok(_) => assert!(true),
    Err(_) => assert!((false)),
}

Auto Trait Implementations

impl Send for Mycelium

impl Sync for Mycelium

impl Unpin for Mycelium

impl !UnwindSafe for Mycelium

impl !RefUnwindSafe for Mycelium

Blanket Implementations

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]