#[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: Ustr
The currency code as an alpha-3 string (e.g., “USD”, “EUR”).
precision: u8
The currency decimal precision.
iso4217: u16
The ISO 4217 currency code.
name: Ustr
The full name of the currency.
currency_type: CurrencyType
The 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 AVAX() -> Self
pub fn BCH() -> 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 DASH() -> Self
pub fn DOT() -> Self
pub fn DOGE() -> Self
pub fn EOS() -> Self
pub fn ETH() -> Self
pub fn ETHW() -> Self
pub fn FDUSD() -> Self
pub fn JOE() -> Self
pub fn LINK() -> Self
pub fn LTC() -> Self
pub fn LUNA() -> Self
pub fn NBT() -> Self
pub fn SOL() -> Self
pub fn SHIB() -> Self
pub fn TRX() -> Self
pub fn TRYB() -> Self
pub fn TUSD() -> Self
pub fn VTC() -> 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:
code
is not a valid string.name
is the empty string.precision
is 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
overwrite
istrue
, any existing currency will be replaced. - If
overwrite
isfalse
and 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
code
does 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§type ThreadChecker = SendablePyClass<Currency>
type ThreadChecker = SendablePyClass<Currency>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
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<Currency> for PyClassImplCollector<Currency>
impl PyClassNewTextSignature<Currency> for PyClassImplCollector<Currency>
fn new_text_signature(self) -> Option<&'static str>
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 type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
PyTypeInfo::type_object
PyTypeInfo::type_object
].§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_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_type_of
PyTypeInfo::is_type_of
].§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.§fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of_bound(object: &Bound<'_, PyAny>) -> bool
PyTypeInfo::is_exact_type_of
PyTypeInfo::is_exact_type_of
].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<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<'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 moreSource§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>
§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