# Struct levana_perpswap_cosmos_msg::prelude::NonZero

`pub struct NonZero<T>(/* private fields */);`

## Expand description

Ensure that the inner value is never 0.

## Implementations§

§### impl<T> NonZero<T>where
T: UnsignedDecimal,

### impl<T> NonZero<T>where T: UnsignedDecimal,

§### impl<T> NonZero<T>where
T: UnsignedDecimal,

### impl<T> NonZero<T>where T: UnsignedDecimal,

#### pub fn to_be_bytes(&self) -> [u8; 32]

#### pub fn to_be_bytes(&self) -> [u8; 32]

Convert into a big-endian array.

#### pub fn from_be_bytes(bytes: [u8; 32]) -> Option<NonZero<T>>

#### pub fn from_be_bytes(bytes: [u8; 32]) -> Option<NonZero<T>>

Convert raw bytes into this value.

Intended for use with cw-storage-plus.

#### pub fn raw(self) -> T

#### pub fn raw(self) -> T

Get the underlying raw value.

#### pub fn into_signed(self) -> Signed<T>

#### pub fn into_signed(self) -> Signed<T>

Turn into a signed value.

#### pub fn into_decimal256(self) -> Decimal256

#### pub fn into_decimal256(self) -> Decimal256

Convert into a general purpose Decimal256.

#### pub fn into_number_gt_zero(self) -> NonZero<Decimal256>

#### pub fn into_number_gt_zero(self) -> NonZero<Decimal256>

Convert into `NonZero<Decimal>`

#### pub fn into_number(self) -> Signed<Decimal256>

#### pub fn into_number(self) -> Signed<Decimal256>

Convert into a general purpose Number.

#### pub fn try_from_number(src: Signed<Decimal256>) -> Option<NonZero<T>>

#### pub fn try_from_number(src: Signed<Decimal256>) -> Option<NonZero<T>>

Try to convert a general purpose Number into this type.

#### pub fn try_from_decimal(src: Decimal256) -> Option<NonZero<T>>

#### pub fn try_from_decimal(src: Decimal256) -> Option<NonZero<T>>

Try to convert a general purpose Decimal256 into this type.

#### pub fn try_from_signed(src: Signed<T>) -> Result<NonZero<T>, Error>

#### pub fn try_from_signed(src: Signed<T>) -> Result<NonZero<T>, Error>

Try to convert a signed value into a non-zero.

#### pub fn checked_add(self, rhs: T) -> Result<NonZero<T>, Error>

#### pub fn checked_add(self, rhs: T) -> Result<NonZero<T>, Error>

Add an unsigned value to this non-zero

This can fail due to overflow error, but is guaranteed to not give a value of 0.

#### pub fn checked_sub(self, rhs: T) -> Result<NonZero<T>, Error>

#### pub fn checked_sub(self, rhs: T) -> Result<NonZero<T>, Error>

Subtract an unsigned value.

This can fail if the result would be either negative or zero.

#### pub fn checked_add_signed(self, rhs: Signed<T>) -> Result<NonZero<T>, Error>

#### pub fn checked_add_signed(self, rhs: Signed<T>) -> Result<NonZero<T>, Error>

Try to add a signed value to this, erroring if it results in a negative or zero result.

#### pub fn checked_sub_signed(self, rhs: Signed<T>) -> Result<NonZero<T>, Error>

#### pub fn checked_sub_signed(self, rhs: Signed<T>) -> Result<NonZero<T>, Error>

Try to subtract a signed value from this, erroring if it results in a negative or zero result.

§### impl NonZero<Collateral>

### impl NonZero<Collateral>

#### pub fn checked_mul_non_zero(
self,
rhs: NonZero<Decimal256>
) -> Result<NonZero<Collateral>, Error>

#### pub fn checked_mul_non_zero( self, rhs: NonZero<Decimal256> ) -> Result<NonZero<Collateral>, Error>

Multiply by the given non-zero decimal.

#### pub fn checked_div_collateral(
self,
rhs: NonZero<Collateral>
) -> Result<NonZero<Decimal256>, Error>

#### pub fn checked_div_collateral( self, rhs: NonZero<Collateral> ) -> Result<NonZero<Decimal256>, Error>

Divide two non-zero collateral values to get the ratio between them.

This can be used for cases like calculating the max gains.

## Trait Implementations§

§### impl<'de, T> Deserialize<'de> for NonZero<T>where
T: UnsignedDecimal,

### impl<'de, T> Deserialize<'de> for NonZero<T>where T: UnsignedDecimal,

§#### fn deserialize<D>(
deserializer: D
) -> Result<NonZero<T>, <D as Deserializer<'de>>::Error>where
D: Deserializer<'de>,

#### fn deserialize<D>( deserializer: D ) -> Result<NonZero<T>, <D as Deserializer<'de>>::Error>where D: Deserializer<'de>,

§### impl<T> Display for NonZero<T>where
T: UnsignedDecimal,

### impl<T> Display for NonZero<T>where T: UnsignedDecimal,

§### impl From<NonZero<Decimal256>> for LeverageToBase

### impl From<NonZero<Decimal256>> for LeverageToBase

§#### fn from(value: NonZero<Decimal256>) -> LeverageToBase

#### fn from(value: NonZero<Decimal256>) -> LeverageToBase

§### impl<T> From<NonZero<T>> for Signed<T>where
T: UnsignedDecimal,

### impl<T> From<NonZero<T>> for Signed<T>where T: UnsignedDecimal,

§### impl<T> FromStr for NonZero<T>where
T: UnsignedDecimal,

### impl<T> FromStr for NonZero<T>where T: UnsignedDecimal,

§### impl<T> JsonSchema for NonZero<T>where
T: UnsignedDecimal,

### impl<T> JsonSchema for NonZero<T>where T: UnsignedDecimal,

§#### fn schema_name() -> String

#### fn schema_name() -> String

§#### fn json_schema(_: &mut SchemaGenerator) -> Schema

#### fn json_schema(_: &mut SchemaGenerator) -> Schema

§#### fn is_referenceable() -> bool

#### fn is_referenceable() -> bool

`$ref`

keyword. Read more§### impl<T> Ord for NonZero<T>where
T: Ord,

### impl<T> Ord for NonZero<T>where T: Ord,

§### impl<T> PartialEq for NonZero<T>where
T: PartialEq,

### impl<T> PartialEq for NonZero<T>where T: PartialEq,

§### impl<T> PartialOrd for NonZero<T>where
T: PartialOrd,

### impl<T> PartialOrd for NonZero<T>where T: PartialOrd,

§#### fn partial_cmp(&self, other: &NonZero<T>) -> Option<Ordering>

#### fn partial_cmp(&self, other: &NonZero<T>) -> Option<Ordering>

1.0.0 · source§#### fn le(&self, other: &Rhs) -> bool

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

`self`

and `other`

) and is used by the `<=`

operator. Read more§### impl<T> Serialize for NonZero<T>where
T: UnsignedDecimal,

### impl<T> Serialize for NonZero<T>where T: UnsignedDecimal,

§#### fn serialize<S>(
&self,
serializer: S
) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where
S: Serializer,

#### fn serialize<S>( &self, serializer: S ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>where S: Serializer,

§### impl<T> TryFrom<&str> for NonZero<T>where
T: UnsignedDecimal,

### impl<T> TryFrom<&str> for NonZero<T>where T: UnsignedDecimal,

§### impl<T> TryFrom<Signed<T>> for NonZero<T>where
T: UnsignedDecimal,

### impl<T> TryFrom<Signed<T>> for NonZero<T>where T: UnsignedDecimal,

§### impl<T> TryFrom<u128> for NonZero<T>where
T: UnsignedDecimal,

### impl<T> TryFrom<u128> for NonZero<T>where T: UnsignedDecimal,

§### impl<T> TryFrom<u64> for NonZero<T>where
T: UnsignedDecimal,

### impl<T> TryFrom<u64> for NonZero<T>where T: UnsignedDecimal,

### impl<T> Copy for NonZero<T>where T: Copy,

### impl<T> Eq for NonZero<T>where T: Eq,

### impl<T> StructuralEq for NonZero<T>

### impl<T> StructuralPartialEq for NonZero<T>

## Auto Trait Implementations§

### impl<T> RefUnwindSafe for NonZero<T>where T: RefUnwindSafe,

### impl<T> Send for NonZero<T>where T: Send,

### impl<T> Sync for NonZero<T>where T: Sync,

### impl<T> Unpin for NonZero<T>where T: Unpin,

### impl<T> UnwindSafe for NonZero<T>where T: UnwindSafe,

## Blanket Implementations§

§### impl<U> As for U

### impl<U> As for U

§#### fn as_<T>(self) -> Twhere
T: CastFrom<U>,

#### fn as_<T>(self) -> Twhere T: CastFrom<U>,

`self`

to type `T`

. The semantics of numeric casting with the `as`

operator are followed, so `<T as As>::as_::<U>`

can be used in the same way as `T as U`

for numeric conversions. Read more