odbc_api::handles

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

Source

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

Like Self::into_result, but SqlResult::NoData is mapped to None, and any success is mapped to Some.

Source

pub fn into_result_with( self, handle: &impl Diagnostics, no_data: Option<T>, need_data: Option<T>, ) -> Result<T, Error>

Most flexible way of converting an SqlResult to an idiomatic Result.

§Parameters
  • handle: This handle is used to extract diagnostics in case self is SqlResult::SuccessWithInfo or SqlResult::Error.
  • error_for_truncation: Intended to be used to be used after bulk fetching into a buffer. If error_for_truncation is true any diagnostics are inspected for truncation. If any truncation is found an error is returned.
  • no_data: Controls the behaviour for SqlResult::NoData. None indicates that the result is never expected to be SqlResult::NoData and would panic in that case. Some(value) would cause SqlResult::NoData to be mapped to Ok(value).
  • need_data: Controls the behaviour for SqlResult::NeedData. None indicates that the result is never expected to be SqlResult::NeedData and would panic in that case. Some(value) would cause SqlResult::NeedData to be mapped to Ok(value).
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 unwrap(self) -> T

Trait Implementations§

Source§

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

Source§

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

Returns a copy 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, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more