#[repr(C)]pub struct Currency {
pub code: Ustr,
pub precision: u8,
pub iso4217: u16,
pub name: Ustr,
pub currency_type: CurrencyType,
}Expand description
Represents a medium of exchange in a specified denomination with a fixed decimal precision.
Handles up to FIXED_PRECISION decimals of precision.
Fields§
§code: UstrThe currency code as an alpha-3 string (e.g., “USD”, “EUR”).
precision: u8The currency decimal precision.
iso4217: u16The ISO 4217 currency code.
name: UstrThe full name of the currency.
currency_type: CurrencyTypeThe currency type, indicating its category (e.g. Fiat, Crypto).
Implementations§
Source§impl Currency
impl Currency
pub fn AUD() -> Self
pub fn BRL() -> Self
pub fn CAD() -> Self
pub fn CHF() -> Self
pub fn CNY() -> Self
pub fn CNH() -> Self
pub fn CZK() -> Self
pub fn DKK() -> Self
pub fn EUR() -> Self
pub fn GBP() -> Self
pub fn HKD() -> Self
pub fn HUF() -> Self
pub fn ILS() -> Self
pub fn INR() -> Self
pub fn JPY() -> Self
pub fn KRW() -> Self
pub fn MXN() -> Self
pub fn NOK() -> Self
pub fn NZD() -> Self
pub fn PLN() -> Self
pub fn RUB() -> Self
pub fn SAR() -> Self
pub fn SEK() -> Self
pub fn SGD() -> Self
pub fn THB() -> Self
pub fn TRY() -> Self
pub fn TWD() -> Self
pub fn USD() -> Self
pub fn ZAR() -> Self
pub fn XAG() -> Self
pub fn XAU() -> Self
pub fn XPT() -> Self
pub fn ONEINCH() -> Self
pub fn AAVE() -> Self
pub fn ACA() -> Self
pub fn ADA() -> Self
pub fn APT() -> Self
pub fn ARB() -> Self
pub fn AVAX() -> Self
pub fn BCH() -> Self
pub fn BIO() -> Self
pub fn BTC() -> Self
pub fn BTTC() -> Self
pub fn BNB() -> Self
pub fn BRZ() -> Self
pub fn BSV() -> Self
pub fn BUSD() -> Self
pub fn CAKE() -> Self
pub fn CRV() -> Self
pub fn DASH() -> Self
pub fn DOT() -> Self
pub fn DOGE() -> Self
pub fn ENA() -> Self
pub fn EOS() -> Self
pub fn ETH() -> Self
pub fn ETHW() -> Self
pub fn FDUSD() -> Self
pub fn HYPE() -> Self
pub fn JOE() -> Self
pub fn LINK() -> Self
pub fn LTC() -> Self
pub fn LUNA() -> Self
pub fn NBT() -> Self
pub fn POL() -> Self
pub fn PROVE() -> Self
pub fn SOL() -> Self
pub fn SHIB() -> Self
pub fn SUI() -> Self
pub fn TON() -> Self
pub fn TRX() -> Self
pub fn TRYB() -> Self
pub fn TUSD() -> Self
pub fn UNI() -> Self
pub fn VTC() -> Self
pub fn WBTC() -> Self
pub fn WSB() -> Self
pub fn XBT() -> Self
pub fn XEC() -> Self
pub fn XLM() -> Self
pub fn XMR() -> Self
pub fn USDT() -> Self
pub fn XRP() -> Self
pub fn XTZ() -> Self
pub fn USDC() -> Self
pub fn USDC_POS() -> Self
pub fn USDP() -> Self
pub fn ZEC() -> Self
Source§impl Currency
impl Currency
Sourcepub fn new_checked<T: AsRef<str>>(
code: T,
precision: u8,
iso4217: u16,
name: T,
currency_type: CurrencyType,
) -> Result<Self>
pub fn new_checked<T: AsRef<str>>( code: T, precision: u8, iso4217: u16, name: T, currency_type: CurrencyType, ) -> Result<Self>
Creates a new Currency instance with correctness checking.
§Errors
Returns an error if:
codeis not a valid string.nameis the empty string.precisionis invalid outside the valid representable range [0, FIXED_PRECISION].
§Notes
PyO3 requires a Result type for proper error handling and stacktrace printing in Python.
Sourcepub fn new<T: AsRef<str>>(
code: T,
precision: u8,
iso4217: u16,
name: T,
currency_type: CurrencyType,
) -> Self
pub fn new<T: AsRef<str>>( code: T, precision: u8, iso4217: u16, name: T, currency_type: CurrencyType, ) -> Self
Creates a new Currency instance.
§Panics
Panics if a correctness check fails. See Currency::new_checked for more details.
Sourcepub fn register(currency: Self, overwrite: bool) -> Result<()>
pub fn register(currency: Self, overwrite: bool) -> Result<()>
Register the given currency in the internal currency map.
- If
overwriteistrue, any existing currency will be replaced. - If
overwriteisfalseand the currency already exists, the operation is a no-op.
§Errors
Returns an error if there is a failure acquiring the lock on the currency map.
Sourcepub fn try_from_str(s: &str) -> Option<Self>
pub fn try_from_str(s: &str) -> Option<Self>
Attempts to parse a Currency from a string, returning None if not found.
Sourcepub fn is_fiat(code: &str) -> Result<bool>
pub fn is_fiat(code: &str) -> Result<bool>
Checks if the currency identified by the given code is a fiat currency.
§Errors
Returns an error if:
- A currency with the given
codedoes not exist. - There is a failure acquiring the lock on the currency map.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Currency
impl<'de> Deserialize<'de> for Currency
Source§fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>where
D: Deserializer<'de>,
Source§impl<'py> IntoPyObject<'py> for Currency
impl<'py> IntoPyObject<'py> for Currency
Source§impl PyClassImpl for Currency
impl PyClassImpl for Currency
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// Represents a medium of exchange in a specified denomination with a fixed decimal precision.
///
/// Handles up to [`FIXED_PRECISION`] decimals of precision.
const RAW_DOC: &'static CStr = /// Represents a medium of exchange in a specified denomination with a fixed decimal precision. /// /// Handles up to [`FIXED_PRECISION`] decimals of precision.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<Currency>
type ThreadChecker = SendablePyClass<Currency>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::ImmutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for Currency
impl PyClassNewTextSignature for Currency
const TEXT_SIGNATURE: &'static str = "(code, precision, iso4217, name, currency_type)"
Source§impl PyMethods<Currency> for PyClassImplCollector<Currency>
impl PyMethods<Currency> for PyClassImplCollector<Currency>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for Currency
impl PyTypeInfo for Currency
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl Copy for Currency
impl DerefToPyAny for Currency
impl Eq for Currency
Auto Trait Implementations§
impl Freeze for Currency
impl RefUnwindSafe for Currency
impl Send for Currency
impl Sync for Currency
impl Unpin for Currency
impl UnwindSafe for Currency
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
impl<T> FromPyObject<'_> for Twhere
T: PyClass + Clone,
§fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
fn extract_bound(obj: &Bound<'_, PyAny>) -> Result<T, PyErr>
§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
§fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
fn from_py_object_bound(ob: Borrowed<'_, 'py, PyAny>) -> Result<T, PyErr>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read more§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
§fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
Source§impl<T> Separable for Twhere
T: Display,
impl<T> Separable for Twhere
T: Display,
Source§fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
fn separate_by_policy(&self, policy: SeparatorPolicy<'_>) -> String
SeparatorPolicy. Read more