Skip to main content

GeneratorContext

Struct GeneratorContext 

Source
pub struct GeneratorContext { /* private fields */ }

Implementations§

Source§

impl GeneratorContext

Source

pub fn new(settings: SqlGeneratorSettings, writer: SqlWriter) -> Self

Source

pub fn for_model( database_model: Rc<DatabaseModel>, database_type: DatabaseType, ) -> Self

Builds a context from just a model and dialect, with an in-memory output sink - for callers (e.g. schema-migration-generator) that only need to call column-level generator methods (column type / check constraint rendering), not run a full CREATE TABLE generation. GenerateOptions::new’s default boolean_mode is Native, so it’s overridden here from database_model.boolean_mode() - the model always carries the real configured mode.

Source

pub fn for_model_with_target_version( database_model: Rc<DatabaseModel>, database_type: DatabaseType, target_version: u32, ) -> Self

Like for_model, but with a target dialect version (PostgreSQL major version, or SQL Server product year) threaded through, for callers (e.g. schema-migration-generator) that need version-gated column type SQL (e.g. json_sql) to match the dialect’s own --postgresql-version/--sqlserver-version target. target_version is interpreted per-dialect and ignored for DatabaseType::Sqlite, which has no version-gated types.

Source

pub fn for_model_with_buffer( database_model: Rc<DatabaseModel>, database_type: DatabaseType, ) -> (Self, BufferSink)

Like for_model, but with the in-memory sink exposed as a readable BufferSink instead of a write-only, inaccessible Vec<u8> - for callers that need to invoke a generator method (e.g. TriggerGenerator::output_triggers_for_table) for its side-effecting writes and then read back what it produced.

Source

pub fn for_model_with_buffer_and_target_version( database_model: Rc<DatabaseModel>, database_type: DatabaseType, target_version: u32, ) -> (Self, BufferSink)

Like for_model_with_buffer, but with a target dialect version - see for_model_with_target_version.

Source

pub fn settings(&self) -> &SqlGeneratorSettings

Source

pub fn shared_settings(&self) -> Rc<SqlGeneratorSettings>

Source

pub fn writer(&self) -> Rc<RefCell<SqlWriter>>

Source

pub fn with_writer<F>(&self, f: F)
where F: FnOnce(&mut SqlWriter),

Trait Implementations§

Source§

impl Clone for GeneratorContext

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

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 = !

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.