pub struct SchemaGenerator { /* private fields */ }Expand description
Schema generator
Implementations§
Source§impl SchemaGenerator
impl SchemaGenerator
pub fn new() -> Self
Sourcepub fn register<T>(
&mut self,
name: &str,
fields: Vec<(&str, SqlType, bool)>,
) -> Result<()>where
T: 'static,
pub fn register<T>(
&mut self,
name: &str,
fields: Vec<(&str, SqlType, bool)>,
) -> Result<()>where
T: 'static,
Register a component type
Sourcepub fn get_schema(&self, type_id: &TypeId) -> Option<&TableSchema>
pub fn get_schema(&self, type_id: &TypeId) -> Option<&TableSchema>
Get schema for a component
Sourcepub fn get_schema_by_name(&self, name: &str) -> Option<&TableSchema>
pub fn get_schema_by_name(&self, name: &str) -> Option<&TableSchema>
Get schema by component name
Sourcepub fn generate_ddl(&self) -> String
pub fn generate_ddl(&self) -> String
Generate CREATE TABLE SQL for all registered components
Sourcepub fn generate_table_ddl(&self, schema: &TableSchema) -> String
pub fn generate_table_ddl(&self, schema: &TableSchema) -> String
Generate CREATE TABLE SQL for a single table
Sourcepub fn generate_index_ddl(&self, table_name: &str, index: &IndexDef) -> String
pub fn generate_index_ddl(&self, table_name: &str, index: &IndexDef) -> String
Generate CREATE INDEX SQL
Sourcepub fn add_index(
&mut self,
type_id: &TypeId,
index_name: &str,
columns: Vec<String>,
unique: bool,
) -> Result<()>
pub fn add_index( &mut self, type_id: &TypeId, index_name: &str, columns: Vec<String>, unique: bool, ) -> Result<()>
Add an index to a component schema
Sourcepub fn list_components(&self) -> Vec<String>
pub fn list_components(&self) -> Vec<String>
List all registered component names
Trait Implementations§
Auto Trait Implementations§
impl Freeze for SchemaGenerator
impl RefUnwindSafe for SchemaGenerator
impl Send for SchemaGenerator
impl Sync for SchemaGenerator
impl Unpin for SchemaGenerator
impl UnwindSafe for SchemaGenerator
Blanket Implementations§
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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