Skip to main content

Schema

Struct Schema 

Source
pub struct Schema { /* private fields */ }
Expand description

An ordered list of top-level fields, optionally named (a table, a record type, a document), and the further tables a schema of several holds (SQL DDL’s CREATE TABLEs).

Keys that span columns (a composite primary key, UNIQUE (a, b), a FOREIGN KEY) are the schema’s own constraints; a key on one column is that field’s.

Implementations§

Source§

impl Schema

Source

pub fn new(fields: impl IntoIterator<Item = Field>) -> Self

A schema of fields, in order.

Source

pub fn of_tables(tables: impl IntoIterator<Item = Schema>) -> Self

A schema of tables, with no fields of its own.

Source

pub fn named(self, name: impl Into<String>) -> Self

Name the schema (a table or type name).

Source

pub fn with_description(self, description: impl Into<String>) -> Self

Describe the schema.

Source

pub fn with_constraint(self, constraint: Constraint) -> Self

Add a table-level constraint.

Source

pub fn with_metadata( self, key: impl Into<String>, value: impl Into<String>, ) -> Self

Add a metadata entry (Arrow’s schema metadata).

Source

pub fn truncated(self, truncated: bool) -> Self

Mark the schema as cut short by a reader’s limit.

Source

pub fn name(&self) -> Option<&str>

The name, if any.

Source

pub fn description(&self) -> Option<&str>

The description, if any.

Source

pub fn fields(&self) -> &[Field]

The top-level fields, in order.

Source

pub fn fields_mut(&mut self) -> &mut Vec<Field>

The top-level fields, to change in place.

Source

pub fn push(&mut self, field: Field) -> &mut Self

Append a field.

Source

pub fn field(&self, name: &str) -> Option<&Field>

The first top-level field called name.

Source

pub fn index_of(&self, name: &str) -> Option<usize>

The position of the first top-level field called name.

Source

pub fn len(&self) -> usize

The number of top-level fields.

Source

pub fn is_empty(&self) -> bool

Whether there are no fields.

Source

pub fn constraints(&self) -> &[Constraint]

The table-level constraints.

Source

pub fn constraints_mut(&mut self) -> &mut Vec<Constraint>

The table-level constraints, to change in place.

Source

pub fn primary_key(&self) -> Vec<&str>

The primary key’s columns: the table’s key when it spans columns, else every field marked as one.

Source

pub fn foreign_keys(&self) -> Vec<ForeignKey>

Every foreign key: the table’s, then each column’s (with the column filled in).

Source

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

The further tables the schema holds.

Source

pub fn tables_mut(&mut self) -> &mut Vec<Schema>

The further tables, to change in place.

Source

pub fn push_table(&mut self, table: Schema) -> &mut Self

Add a table.

Source

pub fn table(&self, name: &str) -> Option<&Schema>

The table called name.

Source

pub fn metadata(&self) -> &[(String, String)]

The metadata entries, in order.

Source

pub fn is_truncated(&self) -> bool

Whether a reader’s limit cut the schema short.

Trait Implementations§

Source§

impl Clone for Schema

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Schema

Source§

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

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

impl Default for Schema

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Eq for Schema

Source§

impl FromIterator<Field> for Schema

Source§

fn from_iter<I: IntoIterator<Item = Field>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl Hash for Schema

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Schema

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Schema

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<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more