pub struct ThinStatus { /* private fields */ }Expand description
Holds a non-OK status code (in most cases ErrorCode), a descriptive string message, and
optionally (if enabled by feature use_any) also [google_cloud_wkt::Any].
It occupies only a single pointer word, which either wraps a tagged integer code (if there is
neither message nor details), or a ThinArc pointer that holds a more complex value.
Furthermore its representation is never nullptr, therefore Option<ThinStatus> and
Result<(), ThinStatus> occupy just a single memory word.
Note that Copy, Eq, PartialOrd and Hash are only provided (derived) when feature
use_any is disabled, since the Any datatype doesn’t provide them.
Implementations§
Source§impl ThinStatus
impl ThinStatus
Sourcepub fn builder<'a, C: Into<NonZeroI32>>(code: C) -> ThinStatusBuilder<'a>
pub fn builder<'a, C: Into<NonZeroI32>>(code: C) -> ThinStatusBuilder<'a>
Constructs a builder that allows convenient creation of ThinStatus instances.
Sourcepub fn from_code<C: Into<NonZeroI32>>(code: C) -> Self
pub fn from_code<C: Into<NonZeroI32>>(code: C) -> Self
A utility function to create a status with just a raw code. If it fits, it’ll be stored just as a tagged integer inside an internal pointer.
Sourcepub fn code(&self) -> Option<ErrorCode>
pub fn code(&self) -> Option<ErrorCode>
Returns the stored error code, or None if the raw numerical value doesn’t match any of the
ErrorCode values.
Sourcepub fn code_or_unknown(&self) -> ErrorCode
pub fn code_or_unknown(&self) -> ErrorCode
Convenience wrapper to code() that converts an unknown error to ErrorCode::Unknown.
Sourcepub fn code_raw(&self) -> NonZeroI32
pub fn code_raw(&self) -> NonZeroI32
Returns the raw numerical error code.
Trait Implementations§
Source§impl Clone for ThinStatus
impl Clone for ThinStatus
Source§fn clone(&self) -> ThinStatus
fn clone(&self) -> ThinStatus
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 ThinStatus
impl Debug for ThinStatus
Source§impl Display for ThinStatus
If the contained error code corresponds to an ErrorCode (code() returns Some(...)), it’s
printed as an upper-case string (such as NOT_FOUND); otherwise just as a number.
This is followed by a colon, space and the contained message (if there is any).
impl Display for ThinStatus
If the contained error code corresponds to an ErrorCode (code() returns Some(...)), it’s
printed as an upper-case string (such as NOT_FOUND); otherwise just as a number.
This is followed by a colon, space and the contained message (if there is any).
impl Eq for ThinStatus
Source§impl Error for ThinStatus
impl Error for ThinStatus
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<&Error> for ThinStatus
impl From<&Error> for ThinStatus
Source§impl From<Error> for ThinStatus
impl From<Error> for ThinStatus
Source§impl From<ErrorCode> for ThinStatus
impl From<ErrorCode> for ThinStatus
Source§impl From<ThinStatusBuilder<'_>> for ThinStatus
impl From<ThinStatusBuilder<'_>> for ThinStatus
Source§fn from(builder: ThinStatusBuilder<'_>) -> Self
fn from(builder: ThinStatusBuilder<'_>) -> Self
Source§impl Hash for ThinStatus
impl Hash for ThinStatus
Source§impl Ord for ThinStatus
impl Ord for ThinStatus
Source§fn cmp(&self, other: &ThinStatus) -> Ordering
fn cmp(&self, other: &ThinStatus) -> Ordering
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for ThinStatus
impl PartialEq for ThinStatus
Source§fn eq(&self, other: &ThinStatus) -> bool
fn eq(&self, other: &ThinStatus) -> bool
self and other values to be equal, and is used by ==.