Struct libesedb::Table

source ·
pub struct Table<'a> { /* private fields */ }
Expand description

Instance of a ESE database table in a currently open crate::EseDb.

Implementations§

source§

impl Table<'_>

source

pub fn name(&self) -> Result<String>

Gets the name of the table.

source

pub fn count_columns(&self) -> Result<i32>

Total number of columns in table.

source

pub fn count_records(&self) -> Result<i32>

Total number of records (rows) in table.

source

pub fn column(&self, entry: i32) -> Result<Column<'_>>

Load a specific column by entry number. Returned Column is bound to the lifetime of the database table.

source

pub fn record(&self, entry: i32) -> Result<Record<'_>>

Load a specific record (row) by entry number. Returned Record is bound to the lifetime of the database table.

source

pub fn iter_columns(&self) -> Result<impl Iterator<Item = Result<Column<'_>>>>

Create an iterator over all the columns in the table. The [IterEntries] iterator and the returned Columns are bound to the lifetime of the database table.

for column in table.iter_columns()? {
    println!("{}", column?.name()?);
}
source

pub fn iter_records(&self) -> Result<impl Iterator<Item = Result<Record<'_>>>>

Create an iterator over all the records (rows) in the table. The [IterEntries] iterator and the returned Records are bound to the lifetime of the database table.

for record in table.iter_records()? {
    let record = record?;
    for value in record.iter_values()? {
        println!("{:?}", value?);
    }
}
Examples found in repository?
examples/fh-catalog-strings.rs (line 10)
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
fn main() {
    let filename = std::env::args()
        .nth(1)
        .unwrap_or("Catalog1.edb".to_string());
    let db = EseDb::open(filename).unwrap();
    println!("Db load finished!");
    let string = db.table_by_name("string").unwrap();
    for rec in string.iter_records().unwrap() {
        let rec = rec.unwrap();
        let vals = rec
            .iter_values()
            .unwrap()
            .map(|v| v.unwrap_or_default().to_string())
            .collect::<Vec<_>>();
        println!("{}", vals.join("\t"));
    }
}
source

pub fn close(self)

When done reading, call this to free resources the table is using in memory.

Trait Implementations§

source§

impl Drop for Table<'_>

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a> RefUnwindSafe for Table<'a>

§

impl<'a> !Send for Table<'a>

§

impl<'a> !Sync for Table<'a>

§

impl<'a> Unpin for Table<'a>

§

impl<'a> UnwindSafe for Table<'a>

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.