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.
Implementations§
Source§impl SqlResult<()>
impl SqlResult<()>
Sourcepub fn into_result_bool(self, handle: &impl Diagnostics) -> Result<bool, Error>
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>
impl<T> SqlResult<T>
Sourcepub fn has_diganostics(&self) -> bool
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.
Sourcepub fn into_result(self, handle: &impl Diagnostics) -> Result<T, Error>
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.
Sourcepub fn into_result_without_logging(
self,
handle: &impl Diagnostics,
) -> Result<T, Error>
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.
Sourcepub fn or_no_data(self) -> SqlResult<Option<T>>
pub fn or_no_data(self) -> SqlResult<Option<T>>
Maps SqlResult::Success
and SqlResult::SuccessWithInfo
to Some
. Maps
SqlResult::NoData
to SqlResult::Success
with None
.
Source§impl SqlResult<()>
impl SqlResult<()>
Sourcepub fn on_success<F, T>(self, f: F) -> SqlResult<T>where
F: FnOnce() -> T,
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>
impl<T> SqlResult<T>
Sourcepub fn is_err(&self) -> bool
pub fn is_err(&self) -> bool
True
if variant is SqlResult::Error
.
Sourcepub fn map<U, F>(self, f: F) -> SqlResult<U>where
F: FnOnce(T) -> U,
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
.
Sourcepub fn on_no_data<F>(self, f: F) -> SqlResult<T>where
F: FnOnce() -> T,
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
.
Sourcepub fn on_need_data<F>(self, f: F) -> SqlResult<T>where
F: FnOnce() -> T,
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
.