pub struct Schema {
pub tables: Vec<Table>,
/* private fields */
}Expand description
A validated collection of tables.
Fields§
§tables: Vec<Table>Implementations§
Source§impl Schema
impl Schema
Sourcepub fn new(tables: Vec<Table>) -> Result<Schema, SchemaError>
pub fn new(tables: Vec<Table>) -> Result<Schema, SchemaError>
Build and validate a schema from a list of tables.
Sourcepub fn table_by_id(&self, id: u32) -> Option<&Table>
pub fn table_by_id(&self, id: u32) -> Option<&Table>
Look up a table by stable id.
Sourcepub fn has_table(&self, name: &str) -> bool
pub fn has_table(&self, name: &str) -> bool
Whether the schema contains a table with the given name.
Sourcepub fn rename_table(&mut self, from: &str, to: &str) -> bool
pub fn rename_table(&mut self, from: &str, to: &str) -> bool
Rename a table in place, keeping the by_name index in sync. Returns
false if from is absent or to is already in use (no change made).
Does not retarget foreign keys — callers that need that should do it
before/after on the tables they own.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Schema
impl<'de> Deserialize<'de> for Schema
Source§fn deserialize<D>(
deserializer: D,
) -> Result<Schema, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
fn deserialize<D>(
deserializer: D,
) -> Result<Schema, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl Serialize for Schema
impl Serialize for Schema
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Serialize this value into the given Serde serializer. Read more
impl StructuralPartialEq for Schema
Auto Trait Implementations§
impl Freeze for Schema
impl RefUnwindSafe for Schema
impl Send for Schema
impl Sync for Schema
impl Unpin for Schema
impl UnsafeUnpin for Schema
impl UnwindSafe for Schema
Blanket Implementations§
impl<T> Allocation for T
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more