Struct Opt

Source
pub struct Opt {
    pub debug: bool,
    pub ugly: bool,
    pub dir: bool,
    pub rust_case: bool,
    pub rustfmt_config: Option<String>,
    pub rustfmt_config_path: Option<String>,
    pub no_functions: bool,
    pub use_tuples: Tuples,
    pub third_party: Vec<ThirdParty>,
    pub conn: String,
    pub output: Option<PathBuf>,
}
Expand description

The program options for the code generation

Fields§

§debug: bool

Activate debug mode

§ugly: bool

Skip running output through rustfmt

§dir: bool

Program will treat output as a directory name rather than a file and generate a whole crate. If output is not provided code is printed as usual

§rust_case: bool

Convert names from the database to rust standard (i.e. table names in CamelCase, fields and functions in snake_case)

§rustfmt_config: Option<String>

string passed to rustfmt –config

§rustfmt_config_path: Option<String>

string passed to rustfmt –config-path

§no_functions: bool

Only make mappings for tables and views

§use_tuples: Tuples

How to use tuples (used by default for just overloads). Options: overloads (the default, use tuples to represent function overloading). all (Have all functions take a tuple for consitency). none (skip mapping overloaded procs at all). one_overload (avoid tuples by only mapping the oldest sql proc in the database).

§third_party: Vec<ThirdParty>

A comma seperated list of third party crates which contain types that will be mapped to and from sql types. Valid values are “bit_vec,chrono,eui48,geo_types,rust_decimal,serde_json,time,uuid”

§conn: String

String to connect to database, see tokio_postgres::Config for details. If not provided environment variable DATABASE_URL is checked instead

§output: Option<PathBuf>

Output file, stdout if not present

Implementations§

Source§

impl Opt

Source

pub fn get_cargo_toml(&self) -> String

Produce the Cargo.toml file contents (the dependecies of the generated code)

Source

pub fn get_call_string(&self) -> String

Build a call string that could be used to get the same options

Source

pub fn get_client(&self) -> MyClient

Trait Implementations§

Source§

impl Debug for Opt

Source§

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

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

impl StructOpt for Opt

Source§

fn clap<'a, 'b>() -> App<'a, 'b>

Returns clap::App corresponding to the struct.
Source§

fn from_clap(matches: &ArgMatches<'_>) -> Self

Builds the struct from clap::ArgMatches. It’s guaranteed to succeed if matches originates from an App generated by StructOpt::clap called on the same type, otherwise it must panic.
Source§

fn from_args() -> Self
where Self: Sized,

Builds the struct from the command line arguments (std::env::args_os). Calls clap::Error::exit on failure, printing the error message and aborting the program.
Source§

fn from_args_safe() -> Result<Self, Error>
where Self: Sized,

Builds the struct from the command line arguments (std::env::args_os). Unlike StructOpt::from_args, returns clap::Error on failure instead of aborting the program, so calling .exit is up to you.
Source§

fn from_iter<I>(iter: I) -> Self
where Self: Sized, I: IntoIterator, <I as IntoIterator>::Item: Into<OsString> + Clone,

Gets the struct from any iterator such as a Vec of your making. Print the error message and quit the program in case of failure. Read more
Source§

fn from_iter_safe<I>(iter: I) -> Result<Self, Error>
where Self: Sized, I: IntoIterator, <I as IntoIterator>::Item: Into<OsString> + Clone,

Gets the struct from any iterator such as a Vec of your making. Read more

Auto Trait Implementations§

§

impl Freeze for Opt

§

impl RefUnwindSafe for Opt

§

impl Send for Opt

§

impl Sync for Opt

§

impl Unpin for Opt

§

impl UnwindSafe for Opt

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> 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V