Trait TryConvert

Source
pub trait TryConvert<T>: Sized {
    type Error;

    // Required method
    fn try_convert(self) -> Result<T, Self::Error>;
}

Required Associated Types§

Required Methods§

Source

fn try_convert(self) -> Result<T, Self::Error>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl TryConvert<(Date, Time)> for Timestamp

Source§

impl TryConvert<DmDateType> for &PgType

Source§

impl TryConvert<PgColumnItem> for (&OdbcColumnItem, &PgColumn)

Source§

impl TryConvert<PgQueryResult> for (QueryResult, &Vec<PgTableItem>, &Options)

Source§

impl TryConvert<Vec<PgColumn>> for (&Vec<OdbcColumn>, &Vec<PgTableItem>, &Options)

Source§

impl TryConvert<BufferDescription> for (&OdbcColumn, &Options)

Source§

impl TryConvert<PgTableDesc> for (TableDescResult, &Options)

Source§

impl TryConvert<PgTableItem> for DmTableItem

Source§

impl TryConvert<Type> for DmDateType

Source§

impl TryConvert<Date> for Date

Convert odbc_api::sys::Date to time::Date

§Example

use odbc_api_helper::TryConvert;

let odbc_data = OdbcDate{year: 2020,month: 1,day: 1};
assert_eq!(date!(2020 - 01 - 01), odbc_data.try_convert().unwrap());

let odbc_data = OdbcDate{year: 2022,month: 12,day: 31};
assert_eq!(date!(2022 - 12 - 31), odbc_data.try_convert().unwrap());
Source§

impl TryConvert<PrimitiveDateTime> for Timestamp

Source§

impl TryConvert<Time> for (Time, u32)

Source§

impl TryConvert<Time> for Time

Convert odbc_api::sys::Time to time::Time

§Example

use odbc_api_helper::TryConvert;

let odbc_time = OdbcTime { hour: 3,minute: 1,second: 1 };
assert_eq!(time!(03 : 01: 01), odbc_time.try_convert().unwrap());

let odbc_time = OdbcTime { hour: 19,minute: 31,second: 59 };
assert_eq!(time!(19 : 31 : 59), odbc_time.try_convert().unwrap());

Implementors§

Source§

impl TryConvert<DmTableDesc> for TableDescResult

Source§

impl<T: StatementInput> TryConvert<Either<Vec<Box<dyn InputParameter>>, ()>> for T

TryConvert State StatementInput trait to EitherBoxParams

§Example

use either::Either;
use odbc_api::parameter::InputParameter;
use odbc_api_helper::executor::statement::Statement;
use odbc_api_helper::extension::pg::PgValueInput;
use odbc_api_helper::TryConvert;

let statement = Statement::new("select * from empty where name=? and age=?",vec![
    PgValueInput::VARCHAR("foo".into()),
    PgValueInput::INT2(8)
]);

let left:Vec<Box<dyn InputParameter>> = statement.try_convert().unwrap().left().unwrap();
assert_eq!(left.len(),2);

let statement = "select * from empty where name=? and age=?";

let right:() = statement.try_convert().unwrap().right().unwrap();///
assert_eq!(right,());