Enum cuprate_rpc_types::Status

source ·
pub enum Status {
    Ok,
    Busy,
    NotMining,
    PaymentRequired,
    Unknown,
}
Expand description

RPC response status.

This type represents monerod’s frequently appearing string field, status.

This field appears within RPC JSON response types.

Reference: https://github.com/monero-project/monero/blob/cc73fe71162d564ffda8e549b79a350bca53c454/src/rpc/core_rpc_server_commands_defs.h#L78-L81.

§Serialization and string formatting

use cuprate_rpc_types::{
    Status,
    CORE_RPC_STATUS_BUSY, CORE_RPC_STATUS_NOT_MINING, CORE_RPC_STATUS_OK,
    CORE_RPC_STATUS_PAYMENT_REQUIRED, CORE_RPC_STATUS_UNKNOWN
};
use serde_json::to_string;

let unknown = Status::Unknown;

assert_eq!(to_string(&Status::Ok).unwrap(),              r#""OK""#);
assert_eq!(to_string(&Status::Busy).unwrap(),            r#""BUSY""#);
assert_eq!(to_string(&Status::NotMining).unwrap(),       r#""NOT MINING""#);
assert_eq!(to_string(&Status::PaymentRequired).unwrap(), r#""PAYMENT REQUIRED""#);
assert_eq!(to_string(&unknown).unwrap(),                 r#""UNKNOWN""#);

assert_eq!(Status::Ok.as_ref(),              CORE_RPC_STATUS_OK);
assert_eq!(Status::Busy.as_ref(),            CORE_RPC_STATUS_BUSY);
assert_eq!(Status::NotMining.as_ref(),       CORE_RPC_STATUS_NOT_MINING);
assert_eq!(Status::PaymentRequired.as_ref(), CORE_RPC_STATUS_PAYMENT_REQUIRED);
assert_eq!(unknown.as_ref(),                 CORE_RPC_STATUS_UNKNOWN);

assert_eq!(format!("{}", Status::Ok),              CORE_RPC_STATUS_OK);
assert_eq!(format!("{}", Status::Busy),            CORE_RPC_STATUS_BUSY);
assert_eq!(format!("{}", Status::NotMining),       CORE_RPC_STATUS_NOT_MINING);
assert_eq!(format!("{}", Status::PaymentRequired), CORE_RPC_STATUS_PAYMENT_REQUIRED);
assert_eq!(format!("{}", unknown),                 CORE_RPC_STATUS_UNKNOWN);

assert_eq!(format!("{:?}", Status::Ok),              "Ok");
assert_eq!(format!("{:?}", Status::Busy),            "Busy");
assert_eq!(format!("{:?}", Status::NotMining),       "NotMining");
assert_eq!(format!("{:?}", Status::PaymentRequired), "PaymentRequired");
assert_eq!(format!("{:?}", unknown),                 "Unknown");

Variants§

§

Ok

Successful RPC response, everything is OK; CORE_RPC_STATUS_OK.

§

Busy

The daemon is busy, try later; CORE_RPC_STATUS_BUSY.

§

NotMining

The daemon is not mining; CORE_RPC_STATUS_NOT_MINING.

§

PaymentRequired

Payment is required for RPC; CORE_RPC_STATUS_PAYMENT_REQUIRED.

§

Unknown

Some unknown other string; CORE_RPC_STATUS_UNKNOWN.

This exists to act as a catch-all if monerod adds a string and a Cuprate node hasn’t updated yet.

The reason this isn’t Unknown(String) is because that disallows Status to be Copy, and thus other types that contain it.

Trait Implementations§

source§

impl AsRef<str> for Status

source§

fn as_ref(&self) -> &str

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Clone for Status

source§

fn clone(&self) -> Status

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl Debug for Status

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Default for Status

source§

fn default() -> Status

Returns the “default value” for a type. Read more
source§

impl<'de> Deserialize<'de> for Status

source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
source§

impl Display for Status

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl EpeeValue for Status

source§

const MARKER: Marker = <String as EpeeValue>::MARKER

source§

fn read<B: Buf>(r: &mut B, marker: &Marker) -> Result<Self>

source§

fn should_write(&self) -> bool

source§

fn epee_default_value() -> Option<Self>

This is different than default field values and instead is the default value of a whole type. Read more
source§

fn write<B: BufMut>(self, w: &mut B) -> Result<()>

source§

impl From<String> for Status

source§

fn from(s: String) -> Self

Converts to this type from the input type.
source§

impl Hash for Status

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl Ord for Status

source§

fn cmp(&self, other: &Status) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl PartialEq for Status

source§

fn eq(&self, other: &Status) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl PartialOrd for Status

source§

fn partial_cmp(&self, other: &Status) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

fn le(&self, other: &Rhs) -> bool

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl Serialize for Status

source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
source§

impl Copy for Status

source§

impl Eq for Status

source§

impl StructuralPartialEq for Status

Auto Trait Implementations§

§

impl Freeze for Status

§

impl RefUnwindSafe for Status

§

impl Send for Status

§

impl Sync for Status

§

impl Unpin for Status

§

impl UnwindSafe for Status

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> CloneToUninit for T
where T: Copy,

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for T
where T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 1 byte

Size for each variant:

  • Ok: 0 bytes
  • Busy: 0 bytes
  • NotMining: 0 bytes
  • PaymentRequired: 0 bytes
  • Unknown: 0 bytes