Trait odbc_api_helper::TryConvert
source · pub trait TryConvert<T>: Sized {
type Error;
fn try_convert(self) -> Result<T, Self::Error>;
}Required Associated Types
Required Methods
fn try_convert(self) -> Result<T, Self::Error>
Implementations on Foreign Types
sourceimpl TryConvert<Type> for DmDateType
impl TryConvert<Type> for DmDateType
sourceimpl TryConvert<PgTableItem> for DmTableItem
impl TryConvert<PgTableItem> for DmTableItem
type Error = Error
fn try_convert(self) -> Result<PgTableItem, Self::Error>
sourceimpl TryConvert<DmDateType> for &PgType
impl TryConvert<DmDateType> for &PgType
type Error = Error
fn try_convert(self) -> Result<DmDateType, Self::Error>
sourceimpl TryConvert<BufferDescription> for (&OdbcColumn, &Options)
impl TryConvert<BufferDescription> for (&OdbcColumn, &Options)
type Error = String
fn try_convert(self) -> Result<BufferDescription, Self::Error>
sourceimpl TryConvert<Date> for Date
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());
sourceimpl TryConvert<Time> for Time
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());
sourceimpl TryConvert<Time> for (Time, u32)
impl TryConvert<Time> for (Time, u32)
sourceimpl TryConvert<(Date, Time)> for Timestamp
impl TryConvert<(Date, Time)> for Timestamp
sourceimpl TryConvert<PrimitiveDateTime> for Timestamp
impl TryConvert<PrimitiveDateTime> for Timestamp
type Error = Error
fn try_convert(self) -> Result<PrimitiveDateTime, Self::Error>
sourceimpl TryConvert<PgTableDesc> for (TableDescResult, &Options)
impl TryConvert<PgTableDesc> for (TableDescResult, &Options)
type Error = Error
fn try_convert(self) -> Result<PgTableDesc, Self::Error>
sourceimpl TryConvert<PgColumnItem> for (&OdbcColumnItem, &PgColumn)
impl TryConvert<PgColumnItem> for (&OdbcColumnItem, &PgColumn)
type Error = String
fn try_convert(self) -> Result<PgColumnItem, Self::Error>
sourceimpl TryConvert<PgQueryResult> for (QueryResult, &Vec<PgTableItem>, &Options)
impl TryConvert<PgQueryResult> for (QueryResult, &Vec<PgTableItem>, &Options)
type Error = String
fn try_convert(self) -> Result<PgQueryResult, Self::Error>
sourceimpl TryConvert<Vec<PgColumn, Global>> for (&Vec<OdbcColumn>, &Vec<PgTableItem>, &Options)
impl TryConvert<Vec<PgColumn, Global>> for (&Vec<OdbcColumn>, &Vec<PgTableItem>, &Options)
Implementors
sourceimpl TryConvert<DmTableDesc> for TableDescResult
impl TryConvert<DmTableDesc> for TableDescResult
sourceimpl<T: StatementInput> TryConvert<Either<Vec<Box<dyn InputParameter + 'static, Global>, Global>, ()>> for T
impl<T: StatementInput> TryConvert<Either<Vec<Box<dyn InputParameter + 'static, Global>, Global>, ()>> 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,());