Skip to main content

PositiveDecimal

Struct PositiveDecimal 

Source
pub struct PositiveDecimal(/* private fields */);
Expand description

A decimal value that must be positive. Wraps rust_decimal::Decimal.

use rust_decimal::Decimal;
use bullet_rust_sdk::PositiveDecimal;

let price = PositiveDecimal::try_from(Decimal::from(50000))?;
let qty = PositiveDecimal::try_from(Decimal::new(1, 3))?; // 0.001

Implementations§

Source§

impl PositiveDecimal

Source

pub const ZERO: PositiveDecimal

The smallest positive value that can be represented by PositiveDecimal.

Source

pub const ONE: PositiveDecimal

Source

pub const TWO: PositiveDecimal

Source

pub const TEN: PositiveDecimal

Source

pub const ONE_HUNDRED: PositiveDecimal

Source

pub const MAX: PositiveDecimal

Source

pub fn new(value: Decimal) -> Option<PositiveDecimal>

Source

pub fn to_fixed(&self, rounding_mode: RoundingMode) -> FixedPositiveDecimal

Source

pub fn as_dec(&self) -> Decimal

Source

pub fn is_zero(&self) -> bool

Source

pub fn fract(&self) -> Decimal

Source

pub fn try_pow_i64(&self, v: i64) -> Result<PositiveDecimal, ArithmeticError>

Source

pub fn try_with_precision( &self, precision: i64, ) -> Result<PositiveDecimal, ArithmeticError>

Source

pub fn saturating_sub(self, v: impl Into<Decimal>) -> PositiveDecimal

Performs a saturating subtraction for PositiveDecimal, this is for intentional saturating subtractions hence no warnings We don’t return a result because we know the saturating subtraction result will always be non-negative

Trait Implementations§

Source§

impl Add for PositiveDecimal

Source§

type Output = PositiveDecimal

The resulting type after applying the + operator.
Source§

fn add(self, other: PositiveDecimal) -> <PositiveDecimal as Add>::Output

Performs the + operation. Read more
Source§

impl BorshDeserialize for PositiveDecimal

Source§

fn deserialize_reader<R>(reader: &mut R) -> Result<PositiveDecimal, Error>
where R: Read,

Source§

fn deserialize(buf: &mut &[u8]) -> Result<Self, Error>

Deserializes this instance from a given slice of bytes. Updates the buffer to point at the remaining bytes.
Source§

fn try_from_slice(v: &[u8]) -> Result<Self, Error>

Deserialize this instance from a slice of bytes.
Source§

fn try_from_reader<R>(reader: &mut R) -> Result<Self, Error>
where R: Read,

Source§

impl BorshSerialize for PositiveDecimal

Source§

fn serialize<__W>(&self, writer: &mut __W) -> Result<(), Error>
where __W: Write,

Source§

impl Clone for PositiveDecimal

Source§

fn clone(&self) -> PositiveDecimal

Returns a duplicate 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 PositiveDecimal

Source§

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

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

impl Default for PositiveDecimal

Source§

fn default() -> PositiveDecimal

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

impl<'de> Deserialize<'de> for PositiveDecimal

Source§

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

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

impl Display for PositiveDecimal

Source§

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

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

impl Div for PositiveDecimal

Source§

type Output = PositiveDecimal

The resulting type after applying the / operator.
Source§

fn div(self, other: PositiveDecimal) -> <PositiveDecimal as Div>::Output

Performs the / operation. Read more
Source§

impl From<FixedPositiveDecimal> for PositiveDecimal

Source§

fn from(value: FixedPositiveDecimal) -> PositiveDecimal

Converts to this type from the input type.
Source§

impl From<u16> for PositiveDecimal

Source§

fn from(value: u16) -> PositiveDecimal

Converts to this type from the input type.
Source§

impl From<u32> for PositiveDecimal

Source§

fn from(value: u32) -> PositiveDecimal

Converts to this type from the input type.
Source§

impl From<u64> for PositiveDecimal

Source§

fn from(value: u64) -> PositiveDecimal

Converts to this type from the input type.
Source§

impl From<u8> for PositiveDecimal

Source§

fn from(value: u8) -> PositiveDecimal

Converts to this type from the input type.
Source§

impl FromStr for PositiveDecimal

Source§

type Err = ConfigError

The associated error which can be returned from parsing.
Source§

fn from_str( s: &str, ) -> Result<PositiveDecimal, <PositiveDecimal as FromStr>::Err>

Parses a string s to return a value of this type. Read more
Source§

impl Hash for PositiveDecimal

Source§

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

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 JsonSchema for PositiveDecimal

Source§

fn schema_name() -> String

The name of the generated JSON Schema. Read more
Source§

fn json_schema(generator: &mut SchemaGenerator) -> Schema

Generates a JSON Schema for this type. Read more
Source§

fn is_referenceable() -> bool

Whether JSON Schemas generated for this type should be re-used where possible using the $ref keyword. Read more
Source§

fn schema_id() -> Cow<'static, str>

Returns a string that uniquely identifies the schema produced by this type. Read more
Source§

impl Mul for PositiveDecimal

Source§

type Output = PositiveDecimal

The resulting type after applying the * operator.
Source§

fn mul(self, other: PositiveDecimal) -> <PositiveDecimal as Mul>::Output

Performs the * operation. Read more
Source§

impl Neg for PositiveDecimal

Source§

type Output = Decimal

The resulting type after applying the - operator.
Source§

fn neg(self) -> Decimal

Performs the unary - operation. Read more
Source§

impl Ord for PositiveDecimal

Source§

fn cmp(&self, other: &PositiveDecimal) -> 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,

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

impl PartialEq for PositiveDecimal

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl PartialOrd for PositiveDecimal

Source§

fn partial_cmp(&self, other: &PositiveDecimal) -> 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

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

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

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl Serialize for PositiveDecimal

Source§

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

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

impl Sub for PositiveDecimal

Source§

type Output = Decimal

The resulting type after applying the - operator.
Source§

fn sub(self, other: PositiveDecimal) -> <PositiveDecimal as Sub>::Output

Performs the - operation. Read more
Source§

impl TryDecimalOps for PositiveDecimal

Source§

impl TryFrom<Decimal> for PositiveDecimal

Source§

type Error = ConfigError

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

fn try_from(value: Decimal) -> Result<PositiveDecimal, ConfigError>

Performs the conversion.
Source§

impl UniversalWallet for PositiveDecimal

Source§

fn scaffold() -> Item<IndexLinking>

Generate the “scaffolding” of the item. If the item is a primtive, this is just the corresponding primtive. If the type is composed of other types, this is the container with all links set to Link::Placeholder.
Ensure that each type contained in the outer type (i.e. the type of each struct/tuple field) is added to the schema, and return a Link connecting the child to the parent. Read more
Source§

fn get_child_templates(schema: &mut Schema) -> TransactionTemplateSet

Empty by default When derived by the macro, builds a template set from annotations on the fields + the field types’ own get_child_templates()
Source§

fn write_schema(schema: &mut Schema) -> Link

Writes the type to the schema if it is not already present and returns a link to it. Read more
Source§

fn make_root_of(schema: &mut Schema)

Writes the type and all its children to the schema, if not already present, and sets the type as a root type. Generates any templates defined on that type.
Source§

fn make_linkable(schema: &mut Schema) -> Link

Gets a link to the type, writing the type to the schema if necessary.
Source§

fn id_override() -> Option<ItemId>

Override the type ID of the item. This should typically not be written by hand. Instead, use the OverrideSchema trait.
Source§

impl Copy for PositiveDecimal

Source§

impl Eq for PositiveDecimal

Source§

impl StructuralPartialEq for PositiveDecimal

Auto Trait Implementations§

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: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

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

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
Source§

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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§

fn to_string(&self) -> String

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

impl<T> ToStringFallible for T
where T: Display,

Source§

fn try_to_string(&self) -> Result<String, TryReserveError>

ToString::to_string, but without panic on OOM.

Source§

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

Source§

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>,

Source§

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<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

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