Enum SqlResult

Source
pub enum SqlResult<T> {
    Success(T),
    SuccessWithInfo(T),
    NoData,
    NeedData,
    StillExecuting,
    Error {
        function: &'static str,
    },
}
Expand description

Result of an ODBC function call. Variants hold the same meaning as the constants associated with SqlReturn. This type may hold results, but it is still the responsibility of the user to fetch and handle the diagnostics in case of an Error.

Variants§

§

Success(T)

The function has been executed successfully.

§

SuccessWithInfo(T)

The function has been executed successfully. There have been warnings.

§

NoData

Meaning depends on the function emitting NoData.

§

NeedData

Emmitted by execute in case delayed parameters have been bound and their input values are now required.

§

StillExecuting

The function was started asynchronously and is still executing.

§

Error

The function returned an error state. Check diagnostics.

Fields

§function: &'static str

Name of the ODBC Api call which caused the error. This might help interpreting associated ODBC diagnostics if the error is bubbled all the way up to the end users output, but the context is lost.

Implementations§

Source§

impl SqlResult<()>

Source

pub fn into_result_bool(self, handle: &impl Diagnostics) -> Result<bool, Error>

Use this instead of Self::into_result if you expect SqlResult::NoData to be a valid value. SqlResult::NoData is mapped to Ok(false), all other success values are Ok(true).

Source§

impl<T> SqlResult<T>

Source

pub fn has_diganostics(&self) -> bool

true for Self::SuccessWithInfo and Self::Error. If true one might expect diagnostic records to be present. If false it would indicate their absense.

Source

pub fn into_result(self, handle: &impl Diagnostics) -> Result<T, Error>

Self::Success and Self::SuccessWithInfo are mapped to Ok. In case of Self::SuccessWithInfo any diagnostics are logged. Self::Error is mapped to error. Other states [Self::NoData] and Self::NeedData would lead to a panic. Most ODBC functions are not suppossed to return these status codes.

Source

pub fn into_result_without_logging( self, handle: &impl Diagnostics, ) -> Result<T, Error>

Self::Success and Self::SuccessWithInfo are mapped to Ok. Self::Error is mapped to error. Other states [Self::NoData] and Self::NeedData would lead to a panic. Most ODBC functions are not suppossed to return these status codes.

In case of Self::Error or Self::SuccessWithInfo no logging of diagnostic records is performed by this method. You may want to use Self::into_result` instead.

Source

pub fn or_no_data(self) -> SqlResult<Option<T>>

Source§

impl SqlResult<()>

Source

pub fn on_success<F, T>(self, f: F) -> SqlResult<T>
where F: FnOnce() -> T,

Append a return value a successful to Result

Source§

impl<T> SqlResult<T>

Source

pub fn is_err(&self) -> bool

True if variant is SqlResult::Error.

Source

pub fn map<U, F>(self, f: F) -> SqlResult<U>
where F: FnOnce(T) -> U,

Applies f to any value wrapped in Success or SuccessWithInfo.

Source

pub fn on_no_data<F>(self, f: F) -> SqlResult<T>
where F: FnOnce() -> T,

Maps Self::NoData to Self::Success with the given value. This makes it easy to chain calls of to SqlResult::on_no_data after calls to SqlResult::on_success.

Source

pub fn on_need_data<F>(self, f: F) -> SqlResult<T>
where F: FnOnce() -> T,

Maps Self::NeedData to Self::Success with the given value. This makes it easy to chain calls of to SqlResult::on_need_data after calls to SqlResult::on_success.

Source

pub fn unwrap(self) -> T

Trait Implementations§

Source§

impl<T: Clone> Clone for SqlResult<T>

Source§

fn clone(&self) -> SqlResult<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: Debug> Debug for SqlResult<T>

Source§

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

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

impl<T: PartialEq> PartialEq for SqlResult<T>

Source§

fn eq(&self, other: &SqlResult<T>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl<T: Copy> Copy for SqlResult<T>

Source§

impl<T: Eq> Eq for SqlResult<T>

Source§

impl<T> StructuralPartialEq for SqlResult<T>

Auto Trait Implementations§

§

impl<T> Freeze for SqlResult<T>
where T: Freeze,

§

impl<T> RefUnwindSafe for SqlResult<T>
where T: RefUnwindSafe,

§

impl<T> Send for SqlResult<T>
where T: Send,

§

impl<T> Sync for SqlResult<T>
where T: Sync,

§

impl<T> Unpin for SqlResult<T>
where T: Unpin,

§

impl<T> UnwindSafe for SqlResult<T>
where T: UnwindSafe,

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