I24

Struct I24 

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

A signed 24-bit integer type.

The I24 type represents a 24-bit signed integer in two’s complement format. It fills the gap between i16 and i32, offering reduced memory usage while preserving a larger numeric range than i16.

This type is particularly suited to applications such as audio processing, binary file manipulation, embedded systems, or networking protocols where 24-bit integers are common.

§Range

The valid value range is:

  MIN = -8_388_608   // -2^23
  MAX =  8_388_607   //  2^23 - 1

Arithmetic operations are implemented to match Rust’s standard integer behavior, including overflow and checked variants.

§Memory Layout and Safety

I24 is implemented as a #[repr(transparent)] wrapper around a 4-byte internal representation. Although the logical width is 24 bits, one additional byte is used for alignment and padding control.

This struct:

The layout is verified via compile-time assertions to ensure portability and correctness.

§Binary Serialization

Although I24 occupies 4 bytes in memory, binary formats (e.g., WAV files, network protocols) often store 24-bit integers in a 3-byte representation. To support this:

For efficient bulk deserialization, use the inherent methods on I24.

Note: Requires the alloc feature to be enabled.

use i24::I24;
let raw: &[u8] = &[0x00, 0x00, 0x01, 0xFF, 0xFF, 0xFF];
let values = I24::read_i24s_be(raw).expect("Test value should convert successfully");
assert_eq!(values[0].to_i32(), 1);
assert_eq!(values[1].to_i32(), -1);

§Usage Notes

  • Use the i24! macro for compile-time checked construction
  • Use .to_i32() to convert to standard Rust types
  • Supports traits like Add, Sub, Display, Hash, Ord, and FromStr

§Features

  • serde: Enables Serialize and Deserialize support via JSON or other formats
  • pyo3: Exposes the I24 type to Python via PyO3 bindings (as I24)
  • alloc: Enables I24DiskMethods for efficient bulk serialization/deserialization

Implementations§

Source§

impl I24

Source

pub const BITS: u32 = 24u32

The size of this integer type in bits

Source

pub const MIN: I24

The smallest value that can be represented by this integer type (-223)

Source

pub const MAX: I24

The largest value that can be represented by this integer type (223 − 1).

Source

pub const ZERO: I24

Creates a new I24 with all bits set to zero.

Source

pub const fn as_bits(&self) -> &u32

Returns a reference to the underlying 32-bit representation.

The 24-bit value is stored in the lower 24 bits, with the upper 8 bits guaranteed to be zero. This method provides direct access to the internal bit representation for advanced use cases.

Source

pub const fn to_bits(self) -> u32

Returns the underlying 32-bit representation.

The 24-bit value is stored in the lower 24 bits, with the upper 8 bits guaranteed to be zero. This method extracts the internal bit representation for advanced use cases.

Source

pub const fn to_i32(self) -> i32

Converts the 24-bit integer to a 32-bit signed integer.

This method performs sign extension if the 24-bit integer is negative.

§Returns

The 32-bit signed integer representation of this I24.

Source

pub const fn wrapping_from_i32(n: i32) -> I24

Creates an I24 from a 32-bit signed integer.

This method truncates the input to 24 bits if it’s outside the valid range.

§Arguments
  • n - The 32-bit signed integer to convert.
§Returns

An I24 instance representing the input value.

Source

pub const fn saturating_from_i32(n: i32) -> I24

Creates an I24 from a 32-bit signed integer.

This method saturates the input if it’s outside the valid range.

§Arguments
  • n - The 32-bit signed integer to convert.
§Returns

An I24 instance representing the input value.

Source

pub const fn swap_bytes(self) -> I24

Reverses the byte order of the integer.

Source

pub const fn to_le(self) -> I24

Converts self to little endian from the target’s endianness. On little endian this is a no-op. On big endian the bytes are swapped.

Source

pub const fn to_be(self) -> I24

Converts self to big endian from the target’s endianness. On big endian this is a no-op. On little endian the bytes are swapped.

Source

pub const fn to_ne_bytes(self) -> [u8; 3]

Return the memory representation of this integer as a byte array in native byte order. As the target platform’s native endianness is used, portable code should use to_be_bytes or to_le_bytes, as appropriate, instead.

Source

pub const fn to_le_bytes(self) -> [u8; 3]

Create a native endian integer value from its representation as a byte array in little endian.

Source

pub const fn to_be_bytes(self) -> [u8; 3]

Return the memory representation of this integer as a byte array in big-endian (network) byte order.

Source

pub const fn from_ne_bytes(bytes: [u8; 3]) -> I24

Creates an I24 from three bytes in native endian order.

§Arguments
  • bytes - An array of 3 bytes representing the 24-bit integer.
§Returns

An I24 instance containing the input bytes.

Source

pub const fn from_le_bytes(bytes: [u8; 3]) -> I24

Creates an I24 from three bytes in little-endian order.

§Arguments
  • bytes - An array of 3 bytes representing the 24-bit integer in little-endian order.
§Returns

An I24 instance containing the input bytes.

Source

pub const fn from_be_bytes(bytes: [u8; 3]) -> I24

Creates an I24 from three bytes in big-endian order.

§Arguments
  • bytes - An array of 3 bytes representing the 24-bit integer in big-endian order.
§Returns

An I24 instance containing the input bytes interpreted as big-endian.

Source

pub fn checked_add(self, other: I24) -> Option<I24>

Performs checked addition.

§Arguments
  • other - The I24 to add to this value.
§Returns

Some(I24) if the addition was successful, or None if it would overflow.

Source

pub fn checked_sub(self, other: I24) -> Option<I24>

Performs checked subtraction.

§Arguments
  • other - The I24 to subtract from this value.
§Returns

Some(I24) if the subtraction was successful, or None if it would overflow.

Source

pub fn checked_mul(self, other: I24) -> Option<I24>

Performs checked multiplication.

§Arguments
  • other - The I24 to multiply with this value.
§Returns

Some(I24) if the multiplication was successful, or None if it would overflow.

Source

pub fn checked_div(self, other: I24) -> Option<I24>

Performs checked division.

§Arguments
  • other - The I24 to divide this value by.
§Returns

Some(I24) if the division was successful, or None if the divisor is zero or if the division would overflow.

Source

pub fn checked_rem(self, other: I24) -> Option<I24>

Performs checked integer remainder.

§Arguments
  • other - The I24 to divide this value by.
§Returns

Some(I24) if the remainder operation was successful, or None if the divisor is zero or if the division would overflow.

Source

pub fn checked_neg(self) -> Option<I24>

Performs checked negation.

§Returns

Some(I24) if the negation was successful, or None if it would overflow. This happens when negating I24::MIN (since -I24::MIN cannot be represented in 24 bits).

Source

pub fn abs(self) -> I24

Computes the absolute value of self.

§Returns

The absolute value of self. Note that I24::MIN.abs() will overflow and wrap to I24::MIN.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(10).expect("Test value should convert successfully").abs(), I24::try_from_i32(10).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(-10).expect("Test value should convert successfully").abs(), I24::try_from_i32(10).expect("Test value should convert successfully"));
Source

pub fn wrapping_abs(self) -> I24

Computes the absolute value of self without any wrapping or panicking.

§Returns

The absolute value of self. For I24::MIN, returns I24::MIN (wrapping behavior).

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(10).expect("Test value should convert successfully").wrapping_abs(), I24::try_from_i32(10).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(-10).expect("Test value should convert successfully").wrapping_abs(), I24::try_from_i32(10).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.wrapping_abs(), I24::MIN); // Wraps around
Source

pub fn saturating_abs(self) -> I24

Computes the absolute value of self, saturating at the bounds instead of overflowing.

§Returns

The absolute value of self. For I24::MIN, returns I24::MAX (saturating behavior).

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(10).expect("Test value should convert successfully").saturating_abs(), I24::try_from_i32(10).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(-10).expect("Test value should convert successfully").saturating_abs(), I24::try_from_i32(10).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.saturating_abs(), I24::MAX); // Saturates to MAX
Source

pub fn signum(self) -> I24

Returns a number representing the sign of self.

§Returns
  • 1 if self is positive
  • 0 if self is zero
  • -1 if self is negative
§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(10).expect("Test value should convert successfully").signum(), I24::try_from_i32(1).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(0).expect("Test value should convert successfully").signum(), I24::try_from_i32(0).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(-10).expect("Test value should convert successfully").signum(), I24::try_from_i32(-1).expect("Test value should convert successfully"));
Source

pub const fn is_negative(self) -> bool

Returns true if self is negative and false if the number is zero or positive.

§Examples
use i24::I24;;
assert!(!I24::try_from_i32(10).expect("Test value should convert successfully").is_negative());
assert!(!I24::try_from_i32(0).expect("Test value should convert successfully").is_negative());
assert!(I24::try_from_i32(-10).expect("Test value should convert successfully").is_negative());
Source

pub const fn is_positive(self) -> bool

Returns true if self is positive and false if the number is zero or negative.

§Examples
use i24::I24;;
assert!(I24::try_from_i32(10).expect("Test value should convert successfully").is_positive());
assert!(!I24::try_from_i32(0).expect("Test value should convert successfully").is_positive());
assert!(!I24::try_from_i32(-10).expect("Test value should convert successfully").is_positive());
Source

pub fn abs_sub(&self, other: &I24) -> I24

The positive difference of two numbers.

Returns zero if the number is less than or equal to the other, otherwise the difference between self and other is returned.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(10).expect("Test value should convert successfully").abs_sub(&I24::try_from_i32(5).expect("Test value should convert successfully")), I24::try_from_i32(5).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(5).expect("Test value should convert successfully").abs_sub(&I24::try_from_i32(10).expect("Test value should convert successfully")), I24::try_from_i32(0).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(10).expect("Test value should convert successfully").abs_sub(&I24::try_from_i32(10).expect("Test value should convert successfully")), I24::try_from_i32(0).expect("Test value should convert successfully"));
Source

pub fn clamp(self, min: I24, max: I24) -> I24

Restricts the value to a certain interval.

Returns max if self is greater than max, and min if self is less than min. Otherwise, returns self.

§Panics

Panics if min > max.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(-3).expect("Test value should convert successfully").clamp(I24::try_from_i32(-2).expect("Test value should convert successfully"), I24::try_from_i32(1).expect("Test value should convert successfully")), I24::try_from_i32(-2).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(0).expect("Test value should convert successfully").clamp(I24::try_from_i32(-2).expect("Test value should convert successfully"), I24::try_from_i32(1).expect("Test value should convert successfully")), I24::try_from_i32(0).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(2).expect("Test value should convert successfully").clamp(I24::try_from_i32(-2).expect("Test value should convert successfully"), I24::try_from_i32(1).expect("Test value should convert successfully")), I24::try_from_i32(1).expect("Test value should convert successfully"));
Source

pub fn min(self, other: I24) -> I24

Computes the minimum of self and other.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(1).expect("Test value should convert successfully").min(I24::try_from_i32(2).expect("Test value should convert successfully")), I24::try_from_i32(1).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(2).expect("Test value should convert successfully").min(I24::try_from_i32(1).expect("Test value should convert successfully")), I24::try_from_i32(1).expect("Test value should convert successfully"));
Source

pub fn max(self, other: I24) -> I24

Computes the maximum of self and other.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(1).expect("Test value should convert successfully").max(I24::try_from_i32(2).expect("Test value should convert successfully")), I24::try_from_i32(2).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(2).expect("Test value should convert successfully").max(I24::try_from_i32(1).expect("Test value should convert successfully")), I24::try_from_i32(2).expect("Test value should convert successfully"));
Source

pub fn wrapping_add(self, rhs: I24) -> I24

Wrapping (modular) addition. Computes self + rhs, wrapping around at the boundary of the type.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").wrapping_add(I24::try_from_i32(27).expect("Test value should convert successfully")), I24::try_from_i32(127).expect("Test value should convert successfully"));
assert_eq!(I24::MAX.wrapping_add(I24::try_from_i32(2).expect("Test value should convert successfully")), I24::MIN + I24::try_from_i32(1).expect("Test value should convert successfully"));
Source

pub fn wrapping_sub(self, rhs: I24) -> I24

Wrapping (modular) subtraction. Computes self - rhs, wrapping around at the boundary of the type.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").wrapping_sub(I24::try_from_i32(100).expect("Test value should convert successfully")), I24::try_from_i32(0).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.wrapping_sub(I24::try_from_i32(1).expect("Test value should convert successfully")), I24::MAX);
Source

pub fn wrapping_mul(self, rhs: I24) -> I24

Wrapping (modular) multiplication. Computes self * rhs, wrapping around at the boundary of the type.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(10).expect("Test value should convert successfully").wrapping_mul(I24::try_from_i32(12).expect("Test value should convert successfully")), I24::try_from_i32(120).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(25).expect("Test value should convert successfully").wrapping_mul(I24::try_from_i32(4).expect("Test value should convert successfully")), I24::try_from_i32(100).expect("Test value should convert successfully"));
Source

pub fn wrapping_div(self, rhs: I24) -> I24

Wrapping (modular) division. Computes self / rhs, wrapping around at the boundary of the type.

The only case where wrapping can occur is when dividing the minimum value by -1, which would overflow but instead wraps to the minimum value.

§Panics

This function will panic if rhs is 0.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").wrapping_div(I24::try_from_i32(10).expect("Test value should convert successfully")), I24::try_from_i32(10).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.wrapping_div(I24::try_from_i32(-1).expect("Test value should convert successfully")), I24::MIN); // Wraps around
Source

pub fn wrapping_rem(self, rhs: I24) -> I24

Wrapping (modular) remainder. Computes self % rhs, wrapping around at the boundary of the type.

The only case where wrapping can occur is when computing the remainder of the minimum value divided by -1, which would overflow but instead wraps to 0.

§Panics

This function will panic if rhs is 0.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").wrapping_rem(I24::try_from_i32(10).expect("Test value should convert successfully")), I24::try_from_i32(0).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.wrapping_rem(I24::try_from_i32(-1).expect("Test value should convert successfully")), I24::try_from_i32(0).expect("Test value should convert successfully")); // Wraps around
Source

pub fn wrapping_neg(self) -> I24

Wrapping (modular) negation. Computes -self, wrapping around at the boundary of the type.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").wrapping_neg(), I24::try_from_i32(-100).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.wrapping_neg(), I24::MIN); // Wraps around
Source

pub fn saturating_add(self, rhs: I24) -> I24

Saturating integer addition. Computes self + rhs, saturating at the numeric bounds.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").saturating_add(I24::try_from_i32(1).expect("Test value should convert successfully")), I24::try_from_i32(101).expect("Test value should convert successfully"));
assert_eq!(I24::MAX.saturating_add(I24::try_from_i32(1).expect("Test value should convert successfully")), I24::MAX);
assert_eq!(I24::MIN.saturating_add(I24::try_from_i32(-1).expect("Test value should convert successfully")), I24::MIN);
Source

pub fn saturating_sub(self, rhs: I24) -> I24

Saturating integer subtraction. Computes self - rhs, saturating at the numeric bounds.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").saturating_sub(I24::try_from_i32(127).expect("Test value should convert successfully")), I24::try_from_i32(-27).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.saturating_sub(I24::try_from_i32(1).expect("Test value should convert successfully")), I24::MIN);
assert_eq!(I24::MAX.saturating_sub(I24::try_from_i32(-1).expect("Test value should convert successfully")), I24::MAX);
Source

pub const fn saturating_mul(self, rhs: I24) -> I24

Saturating integer multiplication. Computes self * rhs, saturating at the numeric bounds.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(10).expect("Test value should convert successfully").saturating_mul(I24::try_from_i32(12).expect("Test value should convert successfully")), I24::try_from_i32(120).expect("Test value should convert successfully"));
assert_eq!(I24::try_from_i32(1000000).expect("Test value should convert successfully").saturating_mul(I24::try_from_i32(10).expect("Test value should convert successfully")), I24::MAX);
assert_eq!(I24::try_from_i32(-1000000).expect("Test value should convert successfully").saturating_mul(I24::try_from_i32(10).expect("Test value should convert successfully")), I24::MIN);
Source

pub fn saturating_div(self, rhs: I24) -> I24

Saturating integer division. Computes self / rhs, saturating at the numeric bounds.

The only case where saturation can occur is when dividing the minimum value by -1, which would overflow but instead saturates to the maximum value.

§Panics

This function will panic if rhs is 0.

§Examples
use i24::I24;;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").saturating_div(I24::try_from_i32(10).expect("Test value should convert successfully")), I24::try_from_i32(10).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.saturating_div(I24::try_from_i32(-1).expect("Test value should convert successfully")), I24::MAX); // Saturates
Source

pub fn saturating_neg(self) -> I24

Saturating integer negation. Computes -self, saturating at the numeric bounds.

§Examples
use i24::I24;
assert_eq!(I24::try_from_i32(100).expect("Test value should convert successfully").saturating_neg(), I24::try_from_i32(-100).expect("Test value should convert successfully"));
assert_eq!(I24::MIN.saturating_neg(), I24::MAX); // Saturates
Source

pub fn read_i24s_le(bytes: &[u8]) -> Option<Vec<I24>>

Converts a byte slice in little-endian order to a Vec of I24 values.

This method interprets the input byte slice as a sequence of 24-bit unsigned integers stored in little-endian format (least significant byte first). Each I24 value requires exactly 3 bytes.

§Arguments
  • bytes - A byte slice containing 24-bit unsigned integers in little-endian format. The length must be a multiple of 3.
§Returns

Some(Vec<I24>) containing the parsed values, or None if the input slice length is not a multiple of 3.

Source

pub const fn read_i24s_le_slice(bytes: &[u8]) -> Option<&[I24]>

Converts a byte slice in little-endian order to a slice of I24 values.

This method interprets the input byte slice as a sequence of 24-bit integers stored in little-endian format. Each I24 value requires exactly 3 bytes.

§Arguments
  • bytes - A byte slice containing 24-bit integers in little-endian format. The length must be a multiple of 3.
§Returns

Some(&[I24]) containing a slice view of the parsed values, or None if the input slice length is not a multiple of 3.

Source

pub fn read_i24s_be(bytes: &[u8]) -> Option<Vec<I24>>

Converts a byte slice in big-endian order to a Vec of I24 values.

This method interprets the input byte slice as a sequence of 24-bit unsigned integers stored in big-endian format (most significant byte first). Each I24 value requires exactly 3 bytes.

§Arguments
  • bytes - A byte slice containing 24-bit unsigned integers in big-endian format. The length must be a multiple of 3.
§Returns

Some(Vec<I24>) containing the parsed values, or None if the input slice length is not a multiple of 3.

Source

pub unsafe fn read_i24s_le_unchecked(bytes: &[u8]) -> Vec<I24>

Reads multiple I24 values from a byte slice in little-endian format without length validation.

§Safety

The input slice length must be a multiple of 3 bytes. Undefined behavior will occur if this precondition is not met.

§Arguments
  • bytes - A byte slice whose length must be a multiple of 3
§Returns

A vector containing the parsed I24 values.

Source

pub unsafe fn read_i24s_le_slice_unchecked(bytes: &[u8]) -> &[I24]

Reads multiple I24 values from a byte slice in little-endian format without length validation.

§Safety

The caller must ensure that bytes.len() is a multiple of 3.

Source

pub unsafe fn read_i24s_be_unchecked(bytes: &[u8]) -> Vec<I24>

Reads multiple I24 values from a byte slice in big-endian format without length validation.

§Safety

The input slice length must be a multiple of 3 bytes. Undefined behavior will occur if this precondition is not met.

§Arguments
  • bytes - A byte slice whose length must be a multiple of 3
§Returns

A vector containing the parsed I24 values.

Source

pub fn write_i24s_le(values: &[I24]) -> Vec<u8>

Converts a slice of I24 values to a Vec of bytes in little-endian order.

Source

pub fn write_i24s_be(values: &[I24]) -> Vec<u8>

Converts a slice of I24 values to a Vec of bytes in big-endian order.

Source

pub fn read_i24s_ne(bytes: &[u8]) -> Option<Vec<I24>>

Reads multiple I24 values from a byte slice in native-endian format.

§Arguments
  • bytes - A byte slice whose length must be a multiple of 3
§Returns

Some(Vec<I24>) containing the parsed values, or None if the input slice length is not a multiple of 3.

Source

pub fn write_i24s_ne(values: &[I24]) -> Vec<u8>

Converts a slice of I24 values to a Vec of bytes in native-endian order.

Source§

impl I24

Source

pub const fn from_u8(value: u8) -> I24

Creates an I24 from a u8 value.

This conversion is guaranteed to succeed as the source type fits within the 24-bit range.

Source§

impl I24

Source

pub const fn from_u16(value: u16) -> I24

Creates an I24 from a u16 value.

This conversion is guaranteed to succeed as the source type fits within the 24-bit range.

Source§

impl I24

Source

pub const fn from_bool(value: bool) -> I24

Creates an I24 from a bool value.

This conversion is guaranteed to succeed as the source type fits within the 24-bit range.

Source§

impl I24

Source

pub const fn from_i8(value: i8) -> I24

Creates an I24 from a i8 value.

This conversion is guaranteed to succeed as the source type fits within the 24-bit range.

Source§

impl I24

Source

pub const fn from_i16(value: i16) -> I24

Creates an I24 from a i16 value.

This conversion is guaranteed to succeed as the source type fits within the 24-bit range.

Source§

impl I24

Source

pub const fn try_from_u32(value: u32) -> Option<I24>

Tries to create an I24 from a u32 value.

Returns Some(I24) if the value fits within the 24-bit signed range [-8,388,608, 8,388,607], or None if the value is out of range.

Source§

impl I24

Source

pub const fn try_from_u64(value: u64) -> Option<I24>

Tries to create an I24 from a u64 value.

Returns Some(I24) if the value fits within the 24-bit signed range [-8,388,608, 8,388,607], or None if the value is out of range.

Source§

impl I24

Source

pub const fn try_from_u128(value: u128) -> Option<I24>

Tries to create an I24 from a u128 value.

Returns Some(I24) if the value fits within the 24-bit signed range [-8,388,608, 8,388,607], or None if the value is out of range.

Source§

impl I24

Source

pub const fn try_from_i32(value: i32) -> Option<I24>

Tries to create an I24 from a i32 value.

Returns Some(I24) if the value fits within the 24-bit signed range [-8,388,608, 8,388,607], or None if the value is out of range.

Source§

impl I24

Source

pub const fn try_from_i64(value: i64) -> Option<I24>

Tries to create an I24 from a i64 value.

Returns Some(I24) if the value fits within the 24-bit signed range [-8,388,608, 8,388,607], or None if the value is out of range.

Source§

impl I24

Source

pub const fn try_from_i128(value: i128) -> Option<I24>

Tries to create an I24 from a i128 value.

Returns Some(I24) if the value fits within the 24-bit signed range [-8,388,608, 8,388,607], or None if the value is out of range.

Trait Implementations§

Source§

impl Add<&I24> for &I24

Source§

type Output = I24

The resulting type after applying the + operator.
Source§

fn add(self, other: &I24) -> I24

Performs the + operation. Read more
Source§

impl Add<&I24> for I24

Source§

type Output = I24

The resulting type after applying the + operator.
Source§

fn add(self, other: &I24) -> I24

Performs the + operation. Read more
Source§

impl Add<I24> for &I24

Source§

type Output = I24

The resulting type after applying the + operator.
Source§

fn add(self, other: I24) -> I24

Performs the + operation. Read more
Source§

impl Add for I24

Source§

type Output = I24

The resulting type after applying the + operator.
Source§

fn add(self, other: I24) -> I24

Performs the + operation. Read more
Source§

impl AddAssign<&I24> for I24

Source§

fn add_assign(&mut self, rhs: &I24)

Performs the += operation. Read more
Source§

impl AddAssign for I24

Source§

fn add_assign(&mut self, rhs: I24)

Performs the += operation. Read more
Source§

impl AudioSample for I24

Source§

const MAX: Self = I24::MAX

Maximum representable value for this sample type.
Source§

const MIN: Self = I24::MIN

Minimum representable value for this sample type.
Source§

const BITS: u8 = 24u8

Bit depth of this sample type.
Source§

const LABEL: &'static str = "I24"

Label used for plotting and display purposes.
Source§

const SAMPLE_TYPE: SampleType = SampleType::I24

Sample type enum variant.
Source§

fn slice_to_bytes(samples: &[Self]) -> Vec<u8>

Convert a slice of samples into a byte vector in native-endian order.
Source§

fn into_inner(self) -> Self

Consumes this sample and returns itself.
Source§

fn to_bytes(self) -> Vec<u8>

Convert this sample into a byte vector in native-endian order.
Source§

fn as_bytes<const N: usize>(&self) -> [u8; N]

Convert this sample into a byte array of specified size (must be supported) in native-endian order.
Source§

const BYTES: usize = _

Byte length
Source§

impl Binary for I24

Source§

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

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

impl BitAnd<&I24> for &I24

Source§

type Output = I24

The resulting type after applying the & operator.
Source§

fn bitand(self, other: &I24) -> I24

Performs the & operation. Read more
Source§

impl BitAnd<&I24> for I24

Source§

type Output = I24

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: &I24) -> I24

Performs the & operation. Read more
Source§

impl BitAnd<I24> for &I24

Source§

type Output = I24

The resulting type after applying the & operator.
Source§

fn bitand(self, other: I24) -> I24

Performs the & operation. Read more
Source§

impl BitAnd for I24

Source§

type Output = I24

The resulting type after applying the & operator.
Source§

fn bitand(self, rhs: I24) -> I24

Performs the & operation. Read more
Source§

impl BitAndAssign<&I24> for I24

Source§

fn bitand_assign(&mut self, rhs: &I24)

Performs the &= operation. Read more
Source§

impl BitAndAssign for I24

Source§

fn bitand_assign(&mut self, rhs: I24)

Performs the &= operation. Read more
Source§

impl BitOr<&I24> for &I24

Source§

type Output = I24

The resulting type after applying the | operator.
Source§

fn bitor(self, other: &I24) -> I24

Performs the | operation. Read more
Source§

impl BitOr<&I24> for I24

Source§

type Output = I24

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: &I24) -> I24

Performs the | operation. Read more
Source§

impl BitOr<I24> for &I24

Source§

type Output = I24

The resulting type after applying the | operator.
Source§

fn bitor(self, other: I24) -> I24

Performs the | operation. Read more
Source§

impl BitOr for I24

Source§

type Output = I24

The resulting type after applying the | operator.
Source§

fn bitor(self, rhs: I24) -> I24

Performs the | operation. Read more
Source§

impl BitOrAssign<&I24> for I24

Source§

fn bitor_assign(&mut self, rhs: &I24)

Performs the |= operation. Read more
Source§

impl BitOrAssign for I24

Source§

fn bitor_assign(&mut self, rhs: I24)

Performs the |= operation. Read more
Source§

impl BitXor<&I24> for &I24

Source§

type Output = I24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: &I24) -> I24

Performs the ^ operation. Read more
Source§

impl BitXor<&I24> for I24

Source§

type Output = I24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: &I24) -> I24

Performs the ^ operation. Read more
Source§

impl BitXor<I24> for &I24

Source§

type Output = I24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, other: I24) -> I24

Performs the ^ operation. Read more
Source§

impl BitXor for I24

Source§

type Output = I24

The resulting type after applying the ^ operator.
Source§

fn bitxor(self, rhs: I24) -> I24

Performs the ^ operation. Read more
Source§

impl BitXorAssign<&I24> for I24

Source§

fn bitxor_assign(&mut self, rhs: &I24)

Performs the ^= operation. Read more
Source§

impl BitXorAssign for I24

Source§

fn bitxor_assign(&mut self, rhs: I24)

Performs the ^= operation. Read more
Source§

impl CastFrom<I24> for I24

Source§

fn cast_from(value: I24) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<I24> for f32

Source§

fn cast_from(value: I24) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<I24> for f64

Source§

fn cast_from(value: I24) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<I24> for i16

Source§

fn cast_from(value: I24) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<I24> for i32

Source§

fn cast_from(value: I24) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<f32> for I24

Source§

fn cast_from(value: f32) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<f64> for I24

Source§

fn cast_from(value: f64) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<i16> for I24

Source§

fn cast_from(value: i16) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<i32> for I24

Source§

fn cast_from(value: i32) -> Self

Cast from the source type to Self.
Source§

impl CastFrom<usize> for I24

Source§

fn cast_from(value: usize) -> Self

Cast from the source type to Self.
Source§

impl CastInto<I24> for I24

Source§

fn cast_into(self) -> I24

Cast self into the target type.
Source§

impl CastInto<I24> for f32

Source§

fn cast_into(self) -> I24

Cast self into the target type.
Source§

impl CastInto<I24> for f64

Source§

fn cast_into(self) -> I24

Cast self into the target type.
Source§

impl CastInto<I24> for i16

Source§

fn cast_into(self) -> I24

Cast self into the target type.
Source§

impl CastInto<I24> for i32

Source§

fn cast_into(self) -> I24

Cast self into the target type.
Source§

impl CastInto<f32> for I24

Source§

fn cast_into(self) -> f32

Cast self into the target type.
Source§

impl CastInto<f64> for I24

Source§

fn cast_into(self) -> f64

Cast self into the target type.
Source§

impl CastInto<i16> for I24

Source§

fn cast_into(self) -> i16

Cast self into the target type.
Source§

impl CastInto<i32> for I24

Source§

fn cast_into(self) -> i32

Cast self into the target type.
Source§

impl Clone for I24

Source§

fn clone(&self) -> I24

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 ConvertTo<I24> for I24

Source§

fn convert_to(&self) -> I24

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl ConvertTo<I24> for f32

Source§

fn convert_to(&self) -> I24

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl ConvertTo<I24> for f64

Source§

fn convert_to(&self) -> I24

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl ConvertTo<I24> for i16

Source§

fn convert_to(&self) -> I24

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl ConvertTo<I24> for i32

Source§

fn convert_to(&self) -> I24

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl ConvertTo<f32> for I24

Source§

fn convert_to(&self) -> f32

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl ConvertTo<f64> for I24

Source§

fn convert_to(&self) -> f64

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl ConvertTo<i16> for I24

Source§

fn convert_to(&self) -> i16

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl ConvertTo<i32> for I24

Source§

fn convert_to(&self) -> i32

Convert this sample to another audio sample type.
Source§

fn convert_from<F: AudioSample + ConvertTo<T>>(source: F) -> T

Convert from another audio sample type to this type. This is a convenience method that calls convert_to on the source value.
Source§

impl Debug for I24

Source§

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

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

impl Default for I24

Source§

fn default() -> I24

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

impl<'de> Deserialize<'de> for I24

Source§

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

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

impl Display for I24

Source§

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

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

impl Div<&I24> for &I24

Source§

type Output = I24

The resulting type after applying the / operator.
Source§

fn div(self, other: &I24) -> I24

Performs the / operation. Read more
Source§

impl Div<&I24> for I24

Source§

type Output = I24

The resulting type after applying the / operator.
Source§

fn div(self, other: &I24) -> I24

Performs the / operation. Read more
Source§

impl Div<I24> for &I24

Source§

type Output = I24

The resulting type after applying the / operator.
Source§

fn div(self, other: I24) -> I24

Performs the / operation. Read more
Source§

impl Div for I24

Source§

type Output = I24

The resulting type after applying the / operator.
Source§

fn div(self, other: I24) -> I24

Performs the / operation. Read more
Source§

impl DivAssign<&I24> for I24

Source§

fn div_assign(&mut self, rhs: &I24)

Performs the /= operation. Read more
Source§

impl DivAssign for I24

Source§

fn div_assign(&mut self, rhs: I24)

Performs the /= operation. Read more
Source§

impl From<bool> for I24

Source§

fn from(value: bool) -> I24

Converts to this type from the input type.
Source§

impl From<i16> for I24

Source§

fn from(value: i16) -> I24

Converts to this type from the input type.
Source§

impl From<i8> for I24

Source§

fn from(value: i8) -> I24

Converts to this type from the input type.
Source§

impl From<u16> for I24

Source§

fn from(value: u16) -> I24

Converts to this type from the input type.
Source§

impl From<u8> for I24

Source§

fn from(value: u8) -> I24

Converts to this type from the input type.
Source§

impl FromPrimitive for I24
where LittleEndianI24Repr: FromPrimitive,

Source§

fn from_i64(n: i64) -> Option<I24>

Converts an i64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u64(n: u64) -> Option<I24>

Converts an u64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_isize(n: isize) -> Option<Self>

Converts an isize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i8(n: i8) -> Option<Self>

Converts an i8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i16(n: i16) -> Option<Self>

Converts an i16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i32(n: i32) -> Option<Self>

Converts an i32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_i128(n: i128) -> Option<Self>

Converts an i128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_usize(n: usize) -> Option<Self>

Converts a usize to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u8(n: u8) -> Option<Self>

Converts an u8 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u16(n: u16) -> Option<Self>

Converts an u16 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u32(n: u32) -> Option<Self>

Converts an u32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_u128(n: u128) -> Option<Self>

Converts an u128 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

fn from_f32(n: f32) -> Option<Self>

Converts a f32 to return an optional value of this type. If the value cannot be represented by this type, then None is returned.
Source§

fn from_f64(n: f64) -> Option<Self>

Converts a f64 to return an optional value of this type. If the value cannot be represented by this type, then None is returned. Read more
Source§

impl FromStr for I24

Source§

type Err = ParseIntError

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

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

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

impl Hash for I24

Source§

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

Feeds this value into the given Hasher. Read more
Source§

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

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

impl LowerHex for I24

Source§

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

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

impl Mul<&I24> for &I24

Source§

type Output = I24

The resulting type after applying the * operator.
Source§

fn mul(self, other: &I24) -> I24

Performs the * operation. Read more
Source§

impl Mul<&I24> for I24

Source§

type Output = I24

The resulting type after applying the * operator.
Source§

fn mul(self, other: &I24) -> I24

Performs the * operation. Read more
Source§

impl Mul<I24> for &I24

Source§

type Output = I24

The resulting type after applying the * operator.
Source§

fn mul(self, other: I24) -> I24

Performs the * operation. Read more
Source§

impl Mul for I24

Source§

type Output = I24

The resulting type after applying the * operator.
Source§

fn mul(self, other: I24) -> I24

Performs the * operation. Read more
Source§

impl MulAssign<&I24> for I24

Source§

fn mul_assign(&mut self, rhs: &I24)

Performs the *= operation. Read more
Source§

impl MulAssign for I24

Source§

fn mul_assign(&mut self, rhs: I24)

Performs the *= operation. Read more
Source§

impl Neg for I24

Source§

type Output = I24

The resulting type after applying the - operator.
Source§

fn neg(self) -> I24

Performs the unary - operation. Read more
Source§

impl Not for I24

Source§

type Output = I24

The resulting type after applying the ! operator.
Source§

fn not(self) -> I24

Performs the unary ! operation. Read more
Source§

impl Num for I24

Source§

type FromStrRadixErr = ParseIntError

Source§

fn from_str_radix( str: &str, radix: u32, ) -> Result<I24, <I24 as Num>::FromStrRadixErr>

Convert from a string and radix (typically 2..=36). Read more
Source§

impl NumCast for I24

Available on crate feature num-cast only.

Implementation of the NumCast trait for I24.

This allows safe casting from any type that implements ToPrimitive to I24. The conversion returns None if the source value cannot be represented within the 24-bit signed integer range [-8,388,608, 8,388,607].

Source§

fn from<T>(n: T) -> Option<I24>
where T: ToPrimitive,

Converts a value of type T to I24.

§Arguments
  • n - The value to convert, which must implement ToPrimitive.
§Returns
  • Some(I24) if the conversion succeeds and the value is within range.
  • None if the conversion fails or the value is out of range.
§Examples
use i24::I24;
use num_traits::NumCast;

// Successful conversions
assert_eq!(<I24 as NumCast>::from(1000i32), Some(I24::try_from_i32(1000).unwrap()));
assert_eq!(<I24 as NumCast>::from(500u16), Some(I24::try_from_i32(500).unwrap()));

// Out of range conversions
assert_eq!(<I24 as NumCast>::from(10_000_000i32), None);
assert_eq!(<I24 as NumCast>::from(-10_000_000i32), None);
Source§

impl Octal for I24

Source§

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

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

impl One for I24

Source§

fn one() -> I24

Returns the multiplicative identity element of Self, 1. Read more
Source§

fn set_one(&mut self)

Sets self to the multiplicative identity element of Self, 1.
Source§

fn is_one(&self) -> bool
where Self: PartialEq,

Returns true if self is equal to the multiplicative identity. Read more
Source§

impl Ord for I24

Source§

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

Source§

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

Source§

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

Source§

type Output = I24

The resulting type after applying the % operator.
Source§

fn rem(self, other: &I24) -> I24

Performs the % operation. Read more
Source§

impl Rem<&I24> for I24

Source§

type Output = I24

The resulting type after applying the % operator.
Source§

fn rem(self, other: &I24) -> I24

Performs the % operation. Read more
Source§

impl Rem<I24> for &I24

Source§

type Output = I24

The resulting type after applying the % operator.
Source§

fn rem(self, other: I24) -> I24

Performs the % operation. Read more
Source§

impl Rem for I24

Source§

type Output = I24

The resulting type after applying the % operator.
Source§

fn rem(self, other: I24) -> I24

Performs the % operation. Read more
Source§

impl RemAssign<&I24> for I24

Source§

fn rem_assign(&mut self, rhs: &I24)

Performs the %= operation. Read more
Source§

impl RemAssign for I24

Source§

fn rem_assign(&mut self, rhs: I24)

Performs the %= operation. Read more
Source§

impl Serialize for I24

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 Shl<u32> for I24

Source§

type Output = I24

The resulting type after applying the << operator.
Source§

fn shl(self, rhs: u32) -> <I24 as Shl<u32>>::Output

Performs the << operation. Read more
Source§

impl ShlAssign<u32> for I24

Source§

fn shl_assign(&mut self, rhs: u32)

Performs the <<= operation. Read more
Source§

impl Shr<u32> for I24

Source§

type Output = I24

The resulting type after applying the >> operator.
Source§

fn shr(self, rhs: u32) -> <I24 as Shr<u32>>::Output

Performs the >> operation. Read more
Source§

impl ShrAssign<u32> for I24

Source§

fn shr_assign(&mut self, rhs: u32)

Performs the >>= operation. Read more
Source§

impl Signed for I24

Source§

fn abs(&self) -> I24

Computes the absolute value. Read more
Source§

fn abs_sub(&self, other: &I24) -> I24

The positive difference of two numbers. Read more
Source§

fn signum(&self) -> I24

Returns the sign of the number. Read more
Source§

fn is_positive(&self) -> bool

Returns true if the number is positive and false if the number is zero or negative.
Source§

fn is_negative(&self) -> bool

Returns true if the number is negative and false if the number is zero or positive.
Source§

impl Sub<&I24> for &I24

Source§

type Output = I24

The resulting type after applying the - operator.
Source§

fn sub(self, other: &I24) -> I24

Performs the - operation. Read more
Source§

impl Sub<&I24> for I24

Source§

type Output = I24

The resulting type after applying the - operator.
Source§

fn sub(self, other: &I24) -> I24

Performs the - operation. Read more
Source§

impl Sub<I24> for &I24

Source§

type Output = I24

The resulting type after applying the - operator.
Source§

fn sub(self, other: I24) -> I24

Performs the - operation. Read more
Source§

impl Sub for I24

Source§

type Output = I24

The resulting type after applying the - operator.
Source§

fn sub(self, other: I24) -> I24

Performs the - operation. Read more
Source§

impl SubAssign<&I24> for I24

Source§

fn sub_assign(&mut self, rhs: &I24)

Performs the -= operation. Read more
Source§

impl SubAssign for I24

Source§

fn sub_assign(&mut self, rhs: I24)

Performs the -= operation. Read more
Source§

impl ToBytes for I24

Source§

type Bytes = [u8; 3]

Source§

fn to_be_bytes(&self) -> <I24 as ToBytes>::Bytes

Return the memory representation of this number as a byte array in big-endian byte order. Read more
Source§

fn to_le_bytes(&self) -> <I24 as ToBytes>::Bytes

Return the memory representation of this number as a byte array in little-endian byte order. Read more
Source§

fn to_ne_bytes(&self) -> Self::Bytes

Return the memory representation of this number as a byte array in native byte order. Read more
Source§

impl ToPrimitive for I24

Source§

fn to_i64(&self) -> Option<i64>

Converts the value of self to an i64. If the value cannot be represented by an i64, then None is returned.
Source§

fn to_u64(&self) -> Option<u64>

Converts the value of self to a u64. If the value cannot be represented by a u64, then None is returned.
Source§

fn to_i32(&self) -> Option<i32>

Converts the value of self to an i32. If the value cannot be represented by an i32, then None is returned.
Source§

fn to_u32(&self) -> Option<u32>

Converts the value of self to a u32. If the value cannot be represented by a u32, then None is returned.
Source§

fn to_i16(&self) -> Option<i16>

Converts the value of self to an i16. If the value cannot be represented by an i16, then None is returned.
Source§

fn to_u16(&self) -> Option<u16>

Converts the value of self to a u16. If the value cannot be represented by a u16, then None is returned.
Source§

fn to_i8(&self) -> Option<i8>

Converts the value of self to an i8. If the value cannot be represented by an i8, then None is returned.
Source§

fn to_u8(&self) -> Option<u8>

Converts the value of self to a u8. If the value cannot be represented by a u8, then None is returned.
Source§

fn to_isize(&self) -> Option<isize>

Converts the value of self to an isize. If the value cannot be represented by an isize, then None is returned.
Source§

fn to_usize(&self) -> Option<usize>

Converts the value of self to a usize. If the value cannot be represented by a usize, then None is returned.
Source§

fn to_f32(&self) -> Option<f32>

Converts the value of self to an f32. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f32.
Source§

fn to_f64(&self) -> Option<f64>

Converts the value of self to an f64. Overflows may map to positive or negative inifinity, otherwise None is returned if the value cannot be represented by an f64. Read more
Source§

fn to_i128(&self) -> Option<i128>

Converts the value of self to an i128. If the value cannot be represented by an i128 (i64 under the default implementation), then None is returned. Read more
Source§

fn to_u128(&self) -> Option<u128>

Converts the value of self to a u128. If the value cannot be represented by a u128 (u64 under the default implementation), then None is returned. Read more
Source§

impl TryFrom<i128> for I24

Source§

type Error = <i8 as TryFrom<i64>>::Error

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

fn try_from(value: i128) -> Result<I24, <I24 as TryFrom<i128>>::Error>

Performs the conversion.
Source§

impl TryFrom<i32> for I24

Source§

type Error = <i8 as TryFrom<i64>>::Error

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

fn try_from(value: i32) -> Result<I24, <I24 as TryFrom<i32>>::Error>

Performs the conversion.
Source§

impl TryFrom<i64> for I24

Source§

type Error = <i8 as TryFrom<i64>>::Error

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

fn try_from(value: i64) -> Result<I24, <I24 as TryFrom<i64>>::Error>

Performs the conversion.
Source§

impl TryFrom<u128> for I24

Source§

type Error = <i8 as TryFrom<i64>>::Error

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

fn try_from(value: u128) -> Result<I24, <I24 as TryFrom<u128>>::Error>

Performs the conversion.
Source§

impl TryFrom<u32> for I24

Source§

type Error = <i8 as TryFrom<i64>>::Error

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

fn try_from(value: u32) -> Result<I24, <I24 as TryFrom<u32>>::Error>

Performs the conversion.
Source§

impl TryFrom<u64> for I24

Source§

type Error = <i8 as TryFrom<i64>>::Error

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

fn try_from(value: u64) -> Result<I24, <I24 as TryFrom<u64>>::Error>

Performs the conversion.
Source§

impl UpperHex for I24

Source§

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

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

impl Zero for I24

Source§

fn zero() -> I24

Returns the additive identity element of Self, 0. Read more
Source§

fn is_zero(&self) -> bool

Returns true if self is equal to the additive identity.
Source§

fn set_zero(&mut self)

Sets self to the additive identity element of Self, 0.
Source§

impl Zeroable for I24
where LittleEndianI24Repr: Zeroable,

Source§

fn zeroed() -> Self

Source§

impl Copy for I24

Source§

impl Eq for I24

Source§

impl NoUninit for I24
where LittleEndianI24Repr: NoUninit,

Source§

impl ScalarOperand for I24

Source§

impl StructuralPartialEq for I24

Auto Trait Implementations§

§

impl Freeze for I24

§

impl RefUnwindSafe for I24

§

impl Send for I24

§

impl Sync for I24

§

impl Unpin for I24

§

impl UnwindSafe for I24

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

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, 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> Castable for T

Source§

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

Source§

impl<T> LinalgScalar for T
where T: One<Output = T> + Add<Output = T> + Sub<Output = T> + 'static + Mul + Copy + Div<Output = T> + Zero,

Source§

impl<T> NumAssign for T
where T: Num + NumAssignOps,

Source§

impl<T, Rhs> NumAssignOps<Rhs> for T
where T: AddAssign<Rhs> + SubAssign<Rhs> + MulAssign<Rhs> + DivAssign<Rhs> + RemAssign<Rhs>,

Source§

impl<T> NumAssignRef for T
where T: NumAssign + for<'r> NumAssignOps<&'r T>,

Source§

impl<T, Rhs, Output> NumOps<Rhs, Output> for T
where T: Sub<Rhs, Output = Output> + Mul<Rhs, Output = Output> + Div<Rhs, Output = Output> + Add<Rhs, Output = Output> + Rem<Rhs, Output = Output>,

Source§

impl<T> NumRef for T
where T: Num + for<'r> NumOps<&'r T>,

Source§

impl<T, Base> RefNum<Base> for T
where T: NumOps<Base, Base> + for<'r> NumOps<&'r Base, Base>,