pub struct AeronCError {
pub code: i32,
/* private fields */
}Expand description
Aeron C API error: code + optional message.
Construction is allocation-free (never reads aeron_errmsg()), so retry loops
that discard the error stay cheap. Attach the message via capture_errmsg()
(at the error site) or with_message(). Otherwise Display and
get_last_err_message_owned() read the live aeron_errmsg() buffer.
Fields§
§code: i32Implementations§
Source§impl AeronCError
impl AeronCError
Sourcepub fn from_code(code: i32) -> Self
pub fn from_code(code: i32) -> Self
Construct from an Aeron error code (< 0 is failure).
Allocation-free; does not read aeron_errmsg(). Use capture_errmsg() to
attach the message when the error will be stored or logged later.
Sourcepub fn with_message(code: i32, msg: impl Into<Cow<'static, str>>) -> Self
pub fn with_message(code: i32, msg: impl Into<Cow<'static, str>>) -> Self
Attach a message. String literals are borrowed without allocating.
An owned String is moved into the error without another copy.
Sourcepub fn message(&self) -> Option<&str>
pub fn message(&self) -> Option<&str>
Message attached via capture_errmsg() / with_message(), if any.
pub const fn kind(&self) -> AeronErrorType
pub fn is_back_pressured(&self) -> bool
pub fn is_admin_action(&self) -> bool
pub fn is_back_pressured_or_admin_action(&self) -> bool
Source§impl AeronCError
impl AeronCError
Sourcepub unsafe fn get_last_err_message(&self) -> &str
pub unsafe fn get_last_err_message(&self) -> &str
Borrow the captured message or the current native thread’s error buffer.
§Safety
If no message was captured, keep this thread alive and do not call native code that changes its error buffer until the returned text is no longer used.
Sourcepub fn get_last_err_message_owned(&self) -> String
pub fn get_last_err_message_owned(&self) -> String
Copy the message into an owned string. This allocates for nonempty text.
Sourcepub fn with_last_err_message<R>(&self, callback: impl FnOnce(&str) -> R) -> R
pub fn with_last_err_message<R>(&self, callback: impl FnOnce(&str) -> R) -> R
Read the message without a heap allocation. Native text is copied to the stack before the callback, so the callback can make other Aeron calls.
Sourcepub fn capture_errmsg(self) -> Self
pub fn capture_errmsg(self) -> Self
Attach the current aeron_errmsg() text to this error (one allocation).
Call at the error site when the error will be stored, logged later, or sent
across threads. Otherwise Display reads the live buffer, which a later
error can overwrite.
Source§impl AeronCError
impl AeronCError
Sourcepub fn is_retryable(&self) -> bool
pub fn is_retryable(&self) -> bool
Transient failure. Retry the operation (back off first). See AeronErrorType::is_retryable.
Sourcepub fn is_unrecoverable(&self) -> bool
pub fn is_unrecoverable(&self) -> bool
Definitively terminal. Abort the operation. See AeronErrorType::is_unrecoverable.
Not exhaustive: ambiguous codes are neither retryable nor unrecoverable.
Trait Implementations§
Source§impl Clone for AeronCError
impl Clone for AeronCError
Source§fn clone(&self) -> AeronCError
fn clone(&self) -> AeronCError
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for AeronCError
impl Debug for AeronCError
Source§impl Display for AeronCError
impl Display for AeronCError
impl Eq for AeronCError
Source§impl Error for AeronCError
impl Error for AeronCError
1.30.0 · Source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
1.0.0 · Source§fn description(&self) -> &str
fn description(&self) -> &str
use the Display impl or to_string()
Source§impl From<AeronErrorType> for AeronCError
impl From<AeronErrorType> for AeronCError
Source§fn from(value: AeronErrorType) -> Self
fn from(value: AeronErrorType) -> Self
Source§impl PartialEq for AeronCError
Equality is on code only. The attached message is advisory.
impl PartialEq for AeronCError
Equality is on code only. The attached message is advisory.