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 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.
Sourcepub fn into_result_option(
self,
handle: &impl Diagnostics,
) -> Result<Option<T>, Error>
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
.
Sourcepub fn into_result_with(
self,
handle: &impl Diagnostics,
no_data: Option<T>,
need_data: Option<T>,
) -> Result<T, Error>
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 caseself
isSqlResult::SuccessWithInfo
orSqlResult::Error
.error_for_truncation
: Intended to be used to be used after bulk fetching into a buffer. Iferror_for_truncation
istrue
any diagnostics are inspected for truncation. If any truncation is found an error is returned.no_data
: Controls the behaviour forSqlResult::NoData
.None
indicates that the result is never expected to beSqlResult::NoData
and would panic in that case.Some(value)
would causeSqlResult::NoData
to be mapped toOk(value)
.need_data
: Controls the behaviour forSqlResult::NeedData
.None
indicates that the result is never expected to beSqlResult::NeedData
and would panic in that case.Some(value)
would causeSqlResult::NeedData
to be mapped toOk(value)
.