Struct rustdb::Database

source ·
pub struct Database {
Show 14 fields pub file: AccessPagedData, pub builtins: Arc<BuiltinMap>, pub sys_schema: Rc<Table>, pub sys_table: Rc<Table>, pub sys_column: Rc<Table>, pub sys_index: Rc<Table>, pub sys_index_col: Rc<Table>, pub sys_function: Rc<Table>, pub schemas: RefCell<FxHashMap<String, i64>>, pub tables: RefCell<FxHashMap<ObjRef, Rc<Table>>>, pub functions: RefCell<FxHashMap<ObjRef, Rc<Function>>>, pub lastid: Cell<i64>, pub err: Cell<bool>, pub is_new: bool, /* private fields */
}
Expand description

Database with SQL-like interface.

Fields§

§file: AccessPagedData

Page storage.

§builtins: Arc<BuiltinMap>

Defined builtin functions.

§sys_schema: Rc<Table>
§sys_table: Rc<Table>
§sys_column: Rc<Table>
§sys_index: Rc<Table>
§sys_index_col: Rc<Table>
§sys_function: Rc<Table>
§schemas: RefCell<FxHashMap<String, i64>>

Cache of loaded Schemas.

§tables: RefCell<FxHashMap<ObjRef, Rc<Table>>>

Cache of loaded Tables.

§functions: RefCell<FxHashMap<ObjRef, Rc<Function>>>

Cache of loaded Functions.

§lastid: Cell<i64>

Last id generated by INSERT.

§err: Cell<bool>

Has there been an error since last save?

§is_new: bool

Is the database new?

Implementations§

source§

impl Database

source

pub fn new( file: AccessPagedData, initsql: &str, builtins: Arc<BuiltinMap> ) -> DB

Construct a new DB, based on the specified file. initsql is used to initialise a new database. builtins specifies the functions callable in SQL code such as SUBSTR, REPLACE etc.

source

pub fn run(self: &DB, source: &str, tr: &mut dyn Transaction)

Run a batch of SQL.

source

pub fn changed(self: &DB) -> bool

Test whether there are unsaved changes.

source

pub fn save(self: &DB) -> usize

Save updated tables to underlying file ( or rollback if there was an error ). Returns the number of logical pages that were updated.

source

pub fn verify(self: &DB) -> String

Verify the page structure of the database.

Trait Implementations§

source§

impl Drop for Database

source§

fn drop(&mut self)

Clear function instructions to avoid leaking memory.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

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

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.