error — functions and constants
The one error model this crate has.
pub fn clear_last_error()
Forget the failure recorded on this thread.
Afterwards last_error_status reports Status::Ok and the
SDK's message is empty. Useful before a call whose failure you
intend to inspect through them rather than through a Result,
so that what you read cannot be an older failure's.
pub fn last_busy_report() -> BusyReport
Why the calling thread's most recent busy refusal happened.
Read it immediately after a call failed with Status::Busy, on
the same thread, exactly as the message is. Thread-local, so a
failure on one thread never reports another's.
Rarely needed directly: Error::busy_reason carries the answer
on the error itself, read at the moment of the failure. This is
here for a caller reading the thread's state, and because the two
halves of that pair must agree.
Cleared by every subsequent call on this thread, successful or
not, so a stale reason can never be read as the cause of an
unrelated error. After a non-busy failure the reason is
BusyReason::Unknown and both strings are empty.
pub fn last_error_status() -> Status
The status of the last failure on this thread, or Status::Ok.
The companion to the message Error already carries, and the
half that is machine-readable. Per-thread, like the message.
Rarely needed from Rust, where every fallible call returns a
Result whose error already carries the status. It is here for
the two cases that cannot: after a raw optris_sdk_sys call made
directly, which does not pass through this crate's status
checking, and to confirm that the status the SDK recorded is the
one the error reports.
Status::Ok means no failure has been recorded on this thread
since one was last cleared, not that the previous call
succeeded: a successful call does not reset it. Use
clear_last_error to establish a known starting point.
pub type Result<T> = std::result::Result<T, Error>;
The result of anything in this crate that can fail.