Skip to main content

EntityCollection

Struct EntityCollection 

Source
pub struct EntityCollection<T> { /* private fields */ }
Available on crate feature std only.
Expand description

Generic DDL entity collection with typed operations.

See module docs for the design rationale. Per-dialect impl EntityCollection<…> blocks supplying entity-aware lookups live in sqlite/collection.rs and postgres/collection.rs.

Implementations§

Source§

impl<T> EntityCollection<T>

Source

pub const fn new() -> EntityCollection<T>

Create empty collection.

Source

pub fn push(&mut self, entity: T)

Push an entity. Always succeeds — duplicate detection is the caller’s responsibility (see module docs).

Source

pub fn list(&self) -> &[T]

List all entities in insertion order.

Source

pub const fn list_mut(&mut self) -> &mut Vec<T>

Mutable access to the underlying Vec.

Source

pub const fn is_empty(&self) -> bool

Check if empty.

Source

pub const fn len(&self) -> usize

Number of entities currently in the collection.

Source§

impl<T> EntityCollection<T>
where T: Clone,

Source

pub fn into_vec(self) -> Vec<T>

Consume the collection and return the underlying Vec.

Source

pub fn update_where<F, P>(&mut self, predicate: P, transform: F)
where F: FnMut(&mut T), P: Fn(&T) -> bool,

Update entities matching predicate with transform.

Source

pub fn update_all<F>(&mut self, transform: F)
where F: FnMut(&mut T),

Update every entity with transform.

Source§

impl EntityCollection<Schema>

Source

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

Source§

impl EntityCollection<Enum>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&Enum>

Source§

impl EntityCollection<Sequence>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&Sequence>

Source§

impl EntityCollection<Role>

Source

pub fn one(&self, name: &str) -> Option<&Role>

Source§

impl EntityCollection<Policy>

Source

pub fn one(&self, schema: &str, table: &str, name: &str) -> Option<&Policy>

Source

pub fn for_table(&self, schema: &str, table: &str) -> Vec<&Policy>

Source§

impl EntityCollection<Table>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&Table>

Source§

impl EntityCollection<Column>

Source

pub fn one(&self, schema: &str, table: &str, name: &str) -> Option<&Column>

Source

pub fn for_table(&self, schema: &str, table: &str) -> Vec<&Column>

Source§

impl EntityCollection<Index>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&Index>

Source

pub fn for_table(&self, schema: &str, table: &str) -> Vec<&Index>

Source§

impl EntityCollection<ForeignKey>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&ForeignKey>

Source

pub fn for_table(&self, schema: &str, table: &str) -> Vec<&ForeignKey>

Source§

impl EntityCollection<PrimaryKey>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&PrimaryKey>

Source

pub fn for_table(&self, schema: &str, table: &str) -> Option<&PrimaryKey>

Source§

impl EntityCollection<UniqueConstraint>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&UniqueConstraint>

Source

pub fn for_table(&self, schema: &str, table: &str) -> Vec<&UniqueConstraint>

Source§

impl EntityCollection<CheckConstraint>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&CheckConstraint>

Source

pub fn for_table(&self, schema: &str, table: &str) -> Vec<&CheckConstraint>

Source§

impl EntityCollection<View>

Source

pub fn one(&self, schema: &str, name: &str) -> Option<&View>

Source§

impl EntityCollection<Table>

Source

pub fn one(&self, name: &str) -> Option<&Table>

Find a table by name

Source

pub fn delete(&mut self, name: &str) -> Option<Table>

Delete a table by name

Source§

impl EntityCollection<Column>

Source

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

Find a column by table and name

Source

pub fn for_table(&self, table: &str) -> Vec<&Column>

List columns for a table

Source

pub fn delete(&mut self, table: &str, name: &str) -> Option<Column>

Delete a column by table and name

Source§

impl EntityCollection<Index>

Source

pub fn one(&self, name: &str) -> Option<&Index>

Find an index by name

Source

pub fn for_table(&self, table: &str) -> Vec<&Index>

List indexes for a table

Source§

impl EntityCollection<ForeignKey>

Source

pub fn one(&self, name: &str) -> Option<&ForeignKey>

Find a foreign key by name

Source

pub fn for_table(&self, table: &str) -> Vec<&ForeignKey>

List foreign keys for a table

Source§

impl EntityCollection<PrimaryKey>

Source

pub fn for_table(&self, table: &str) -> Option<&PrimaryKey>

Find a primary key by table

Source§

impl EntityCollection<UniqueConstraint>

Source

pub fn one(&self, name: &str) -> Option<&UniqueConstraint>

Find by name

Source

pub fn for_table(&self, table: &str) -> Vec<&UniqueConstraint>

List for a table

Source§

impl EntityCollection<CheckConstraint>

Source

pub fn one(&self, name: &str) -> Option<&CheckConstraint>

Find by name

Source

pub fn for_table(&self, table: &str) -> Vec<&CheckConstraint>

List for a table

Source§

impl EntityCollection<View>

Source

pub fn one(&self, name: &str) -> Option<&View>

Find a view by name

Trait Implementations§

Source§

impl<T> Clone for EntityCollection<T>
where T: Clone,

Source§

fn clone(&self) -> EntityCollection<T>

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<T> Debug for EntityCollection<T>
where T: Debug,

Source§

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

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

impl<T> Default for EntityCollection<T>

Source§

fn default() -> EntityCollection<T>

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

impl<T> Extend<T> for EntityCollection<T>

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = T>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more

Auto Trait Implementations§

§

impl<T> Freeze for EntityCollection<T>
where Vec<T>: Freeze,

§

impl<T> RefUnwindSafe for EntityCollection<T>
where Vec<T>: RefUnwindSafe,

§

impl<T> Send for EntityCollection<T>
where Vec<T>: Send,

§

impl<T> Sync for EntityCollection<T>
where Vec<T>: Sync,

§

impl<T> Unpin for EntityCollection<T>
where Vec<T>: Unpin,

§

impl<T> UnsafeUnpin for EntityCollection<T>
where Vec<T>: UnsafeUnpin,

§

impl<T> UnwindSafe for EntityCollection<T>
where Vec<T>: UnwindSafe,

Blanket Implementations§

Source§

impl<T> AliasExt for T

Source§

fn alias(self, name: &'static str) -> AliasedExpr<Self>

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<Mk> MarkerAggValidFor<()> for Mk

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<Scope> ScopeSatisfies<Nil, ()> for Scope

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

impl<T> TypeEq<T> for T