pub enum DbInstance {
Mem(Db<MemStorage>),
Sqlite(Db<SqliteStorage>),
}Expand description
A dispatcher for concrete storage implementations, wrapping Db. This is done so that client code does not have to deal with generic code constantly. You may prefer to use Db directly, especially if you provide a custom storage engine.
Many methods are dispatching methods for the corresponding methods on Db.
Other methods are wrappers simplifying signatures to deal with only strings. These methods made code for interop with other languages much easier, but are not desirable if you are using Rust.
Variants§
Implementations§
Source§impl DbInstance
impl DbInstance
Sourcepub fn new(engine: &str, path: impl AsRef<Path>, options: &str) -> Result<Self>
pub fn new(engine: &str, path: impl AsRef<Path>, options: &str) -> Result<Self>
Create a DbInstance, which is a dispatcher for various concrete implementations. The valid engines are:
memsqliterocksdbnewrocksdbsledtikv
assuming all features are enabled during compilation. Otherwise only
some of the engines are available. The mem engine is always available.
path is ignored for mem and tikv engines.
options is ignored for every engine except tikv.
Sourcepub fn new_with_str(
engine: &str,
path: &str,
options: &str,
) -> Result<Self, String>
pub fn new_with_str( engine: &str, path: &str, options: &str, ) -> Result<Self, String>
Same as Self::new, but inputs and error messages are all in strings
Sourcepub fn get_fixed_rules(&self) -> BTreeMap<String, Arc<Box<dyn FixedRule>>>
pub fn get_fixed_rules(&self) -> BTreeMap<String, Arc<Box<dyn FixedRule>>>
Dispatcher method. See crate::Db::get_fixed_rules.
Sourcepub fn run_script(
&self,
payload: &str,
params: BTreeMap<String, DataValue>,
mutability: ScriptMutability,
) -> Result<NamedRows>
pub fn run_script( &self, payload: &str, params: BTreeMap<String, DataValue>, mutability: ScriptMutability, ) -> Result<NamedRows>
Dispatcher method. See crate::Db::run_script.
Sourcepub fn run_default(&self, payload: &str) -> Result<NamedRows>
pub fn run_default(&self, payload: &str) -> Result<NamedRows>
run_script with mutable script and no parameters
Sourcepub fn run_script_ast(
&self,
payload: CozoScript,
cur_vld: ValidityTs,
mutability: ScriptMutability,
) -> Result<NamedRows>
pub fn run_script_ast( &self, payload: CozoScript, cur_vld: ValidityTs, mutability: ScriptMutability, ) -> Result<NamedRows>
Run a parsed (AST) program. If you have a string script, use run_script or run_default.
Sourcepub fn run_script_fold_err(
&self,
payload: &str,
params: BTreeMap<String, DataValue>,
mutability: ScriptMutability,
) -> JsonValue
pub fn run_script_fold_err( &self, payload: &str, params: BTreeMap<String, DataValue>, mutability: ScriptMutability, ) -> JsonValue
Run the CozoScript passed in. The params argument is a map of parameters.
Fold any error into the return JSON itself.
See crate::Db::run_script.
Sourcepub fn run_script_str(
&self,
payload: &str,
params: &str,
immutable: bool,
) -> String
pub fn run_script_str( &self, payload: &str, params: &str, immutable: bool, ) -> String
Run the CozoScript passed in. The params argument is a map of parameters formatted as JSON.
See crate::Db::run_script.
Sourcepub fn export_relations<I, T>(
&self,
relations: I,
) -> Result<BTreeMap<String, NamedRows>>
pub fn export_relations<I, T>( &self, relations: I, ) -> Result<BTreeMap<String, NamedRows>>
Dispatcher method. See crate::Db::export_relations.
Sourcepub fn export_relations_str(&self, data: &str) -> String
pub fn export_relations_str(&self, data: &str) -> String
Export relations to JSON-encoded string. See crate::Db::export_relations
Sourcepub fn import_relations(&self, data: BTreeMap<String, NamedRows>) -> Result<()>
pub fn import_relations(&self, data: BTreeMap<String, NamedRows>) -> Result<()>
Dispatcher method. See crate::Db::import_relations.
Sourcepub fn import_relations_str(&self, data: &str) -> String
pub fn import_relations_str(&self, data: &str) -> String
Import a relation, the data is given as a JSON string, and the returned result is converted into a string. See crate::Db::import_relations.
Sourcepub fn import_relations_str_with_err(&self, data: &str) -> Result<()>
pub fn import_relations_str_with_err(&self, data: &str) -> Result<()>
Import a relation, the data is given as a JSON string. See crate::Db::import_relations.
Sourcepub fn backup_db(&self, out_file: impl AsRef<Path>) -> Result<()>
pub fn backup_db(&self, out_file: impl AsRef<Path>) -> Result<()>
Dispatcher method. See crate::Db::backup_db.
Sourcepub fn backup_db_str(&self, out_file: impl AsRef<Path>) -> String
pub fn backup_db_str(&self, out_file: impl AsRef<Path>) -> String
Backup the running database into an Sqlite file, with JSON string return value. See crate::Db::backup_db.
Sourcepub fn restore_backup(&self, in_file: impl AsRef<Path>) -> Result<()>
pub fn restore_backup(&self, in_file: impl AsRef<Path>) -> Result<()>
Dispatcher method. See crate::Db::restore_backup.
Sourcepub fn restore_backup_str(&self, in_file: impl AsRef<Path>) -> String
pub fn restore_backup_str(&self, in_file: impl AsRef<Path>) -> String
Restore from an Sqlite backup, with JSON string return value. See crate::Db::restore_backup.
Sourcepub fn import_from_backup(
&self,
in_file: impl AsRef<Path>,
relations: &[String],
) -> Result<()>
pub fn import_from_backup( &self, in_file: impl AsRef<Path>, relations: &[String], ) -> Result<()>
Dispatcher method. See crate::Db::import_from_backup.
Sourcepub fn import_from_backup_str(&self, payload: &str) -> String
pub fn import_from_backup_str(&self, payload: &str) -> String
Import relations from an Sqlite backup, with JSON string return value. See crate::Db::import_from_backup.
Sourcepub fn register_callback(
&self,
relation: &str,
capacity: Option<usize>,
) -> (u32, Receiver<(CallbackOp, NamedRows, NamedRows)>)
pub fn register_callback( &self, relation: &str, capacity: Option<usize>, ) -> (u32, Receiver<(CallbackOp, NamedRows, NamedRows)>)
Dispatcher method. See crate::Db::register_callback.
Sourcepub fn unregister_callback(&self, id: u32) -> bool
pub fn unregister_callback(&self, id: u32) -> bool
Dispatcher method. See crate::Db::unregister_callback.
Sourcepub fn register_fixed_rule<R>(&self, name: String, rule_impl: R) -> Result<()>where
R: FixedRule + 'static,
pub fn register_fixed_rule<R>(&self, name: String, rule_impl: R) -> Result<()>where
R: FixedRule + 'static,
Dispatcher method. See crate::Db::register_fixed_rule.
Sourcepub fn unregister_fixed_rule(&self, name: &str) -> Result<bool>
pub fn unregister_fixed_rule(&self, name: &str) -> Result<bool>
Dispatcher method. See crate::Db::unregister_fixed_rule
Sourcepub fn run_multi_transaction(
&self,
write: bool,
payloads: Receiver<TransactionPayload>,
results: Sender<Result<NamedRows>>,
)
pub fn run_multi_transaction( &self, write: bool, payloads: Receiver<TransactionPayload>, results: Sender<Result<NamedRows>>, )
Dispatcher method. See crate::Db::run_multi_transaction
Sourcepub fn multi_transaction(&self, write: bool) -> MultiTransaction
pub fn multi_transaction(&self, write: bool) -> MultiTransaction
A higher-level, blocking wrapper for crate::Db::run_multi_transaction. Runs the transaction on a dedicated thread. Write transactions may block other reads, but we guarantee that this does not happen for the RocksDB backend.
Trait Implementations§
Source§impl Clone for DbInstance
impl Clone for DbInstance
Source§fn clone(&self) -> DbInstance
fn clone(&self) -> DbInstance
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for DbInstance
impl RefUnwindSafe for DbInstance
impl Send for DbInstance
impl Sync for DbInstance
impl Unpin for DbInstance
impl UnwindSafe for DbInstance
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<D> OwoColorize for D
impl<D> OwoColorize for D
Source§fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
fn fg<C>(&self) -> FgColorDisplay<'_, C, Self>where
C: Color,
Source§fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
fn bg<C>(&self) -> BgColorDisplay<'_, C, Self>where
C: Color,
Source§fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
fn black<'a>(&'a self) -> FgColorDisplay<'a, Black, Self>
Source§fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
fn on_black<'a>(&'a self) -> BgColorDisplay<'a, Black, Self>
Source§fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
fn red<'a>(&'a self) -> FgColorDisplay<'a, Red, Self>
Source§fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
fn on_red<'a>(&'a self) -> BgColorDisplay<'a, Red, Self>
Source§fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
fn green<'a>(&'a self) -> FgColorDisplay<'a, Green, Self>
Source§fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
fn on_green<'a>(&'a self) -> BgColorDisplay<'a, Green, Self>
Source§fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
fn yellow<'a>(&'a self) -> FgColorDisplay<'a, Yellow, Self>
Source§fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
fn on_yellow<'a>(&'a self) -> BgColorDisplay<'a, Yellow, Self>
Source§fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
fn blue<'a>(&'a self) -> FgColorDisplay<'a, Blue, Self>
Source§fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
fn on_blue<'a>(&'a self) -> BgColorDisplay<'a, Blue, Self>
Source§fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn magenta<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Source§fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_magenta<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Source§fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
fn purple<'a>(&'a self) -> FgColorDisplay<'a, Magenta, Self>
Source§fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
fn on_purple<'a>(&'a self) -> BgColorDisplay<'a, Magenta, Self>
Source§fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
fn cyan<'a>(&'a self) -> FgColorDisplay<'a, Cyan, Self>
Source§fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
fn on_cyan<'a>(&'a self) -> BgColorDisplay<'a, Cyan, Self>
Source§fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
fn white<'a>(&'a self) -> FgColorDisplay<'a, White, Self>
Source§fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
fn on_white<'a>(&'a self) -> BgColorDisplay<'a, White, Self>
Source§fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
fn default_color<'a>(&'a self) -> FgColorDisplay<'a, Default, Self>
Source§fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
fn on_default_color<'a>(&'a self) -> BgColorDisplay<'a, Default, Self>
Source§fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
fn bright_black<'a>(&'a self) -> FgColorDisplay<'a, BrightBlack, Self>
Source§fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
fn on_bright_black<'a>(&'a self) -> BgColorDisplay<'a, BrightBlack, Self>
Source§fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
fn bright_red<'a>(&'a self) -> FgColorDisplay<'a, BrightRed, Self>
Source§fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
fn on_bright_red<'a>(&'a self) -> BgColorDisplay<'a, BrightRed, Self>
Source§fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
fn bright_green<'a>(&'a self) -> FgColorDisplay<'a, BrightGreen, Self>
Source§fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
fn on_bright_green<'a>(&'a self) -> BgColorDisplay<'a, BrightGreen, Self>
Source§fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
fn bright_yellow<'a>(&'a self) -> FgColorDisplay<'a, BrightYellow, Self>
Source§fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
fn on_bright_yellow<'a>(&'a self) -> BgColorDisplay<'a, BrightYellow, Self>
Source§fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
fn bright_blue<'a>(&'a self) -> FgColorDisplay<'a, BrightBlue, Self>
Source§fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
fn on_bright_blue<'a>(&'a self) -> BgColorDisplay<'a, BrightBlue, Self>
Source§fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_magenta<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Source§fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_magenta<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Source§fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
fn bright_purple<'a>(&'a self) -> FgColorDisplay<'a, BrightMagenta, Self>
Source§fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
fn on_bright_purple<'a>(&'a self) -> BgColorDisplay<'a, BrightMagenta, Self>
Source§fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
fn bright_cyan<'a>(&'a self) -> FgColorDisplay<'a, BrightCyan, Self>
Source§fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
fn on_bright_cyan<'a>(&'a self) -> BgColorDisplay<'a, BrightCyan, Self>
Source§fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
fn bright_white<'a>(&'a self) -> FgColorDisplay<'a, BrightWhite, Self>
Source§fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
fn on_bright_white<'a>(&'a self) -> BgColorDisplay<'a, BrightWhite, Self>
Source§fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
fn bold<'a>(&'a self) -> BoldDisplay<'a, Self>
Source§fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
fn dimmed<'a>(&'a self) -> DimDisplay<'a, Self>
Source§fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
fn italic<'a>(&'a self) -> ItalicDisplay<'a, Self>
Source§fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
fn underline<'a>(&'a self) -> UnderlineDisplay<'a, Self>
Source§fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
fn blink<'a>(&'a self) -> BlinkDisplay<'a, Self>
Source§fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
fn blink_fast<'a>(&'a self) -> BlinkFastDisplay<'a, Self>
Source§fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
fn reversed<'a>(&'a self) -> ReversedDisplay<'a, Self>
Source§fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
fn strikethrough<'a>(&'a self) -> StrikeThroughDisplay<'a, Self>
Source§fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn color<Color>(&self, color: Color) -> FgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::fg or
a color-specific method, such as OwoColorize::green, Read moreSource§fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
fn on_color<Color>(&self, color: Color) -> BgDynColorDisplay<'_, Color, Self>where
Color: DynColor,
OwoColorize::bg or
a color-specific method, such as OwoColorize::on_yellow, Read more