Skip to main content

Relation

Struct Relation 

Source
pub struct Relation {
    pub entries: Vec<RelationEntry>,
    pub tables: Vec<String>,
    pub table_column_counts: Vec<usize>,
}
Expand description

A relation is a collection of entries with table context.

Fields§

§entries: Vec<RelationEntry>

The entries in this relation.

§tables: Vec<String>

Table names in this relation.

§table_column_counts: Vec<usize>

Column counts for each table (used for computing offsets in joined relations). The i-th element is the number of columns in the i-th table.

Implementations§

Source§

impl Relation

Source

pub fn new(tables: Vec<String>) -> Self

Creates a new empty relation.

Source

pub fn new_with_column_counts( tables: Vec<String>, column_counts: Vec<usize>, ) -> Self

Creates a new empty relation with column counts.

Source

pub fn empty() -> Self

Creates an empty relation.

Source

pub fn from_rows(rows: Vec<Rc<Row>>, tables: Vec<String>) -> Self

Creates a relation from Rcs. Uses shared tables to avoid cloning for each row.

Source

pub fn from_rows_with_column_count( rows: Vec<Rc<Row>>, tables: Vec<String>, column_count: usize, ) -> Self

Creates a relation from Rcs with explicit column count.

Source

pub fn from_rows_owned(rows: Vec<Row>, tables: Vec<String>) -> Self

Creates a relation from owned Rows. Uses shared tables to avoid cloning for each row.

Source

pub fn tables(&self) -> &[String]

Returns the tables in this relation.

Source

pub fn table_column_counts(&self) -> &[usize]

Returns the column counts for each table.

Source

pub fn get_table_offset(&self, table_name: &str) -> Option<usize>

Computes the column offset for a given table name. Returns None if the table is not found.

Source

pub fn len(&self) -> usize

Returns the number of entries.

Source

pub fn is_empty(&self) -> bool

Returns true if the relation is empty.

Source

pub fn push(&mut self, entry: RelationEntry)

Adds an entry to the relation.

Source

pub fn iter(&self) -> impl Iterator<Item = &RelationEntry>

Returns an iterator over the entries.

Trait Implementations§

Source§

impl Clone for Relation

Source§

fn clone(&self) -> Relation

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Relation

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl IntoIterator for Relation

Source§

type Item = RelationEntry

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<RelationEntry>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

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>,

Source§

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.