Skip to content
API REFERENCEUsage guides →

cellpack::format::cpk::Dtype ​

enum

Module contract · All interfaces

At a glance ​

pub enum Dtype {
    U8,
    U16,
    U32,
    U64,
    I8,
    I16,
    I32,
    I64,
    F32,
    F64,
}

Numeric type of a matrix’s values; its width is the chunks’ value width.

The discriminant is the code stored in the superblock’s dtype byte, so the declaration order is part of the file format and cannot be rearranged without changing the version.

Fields and variants ​

U8 ​

U8

Unsigned, 1 byte (code 0).

U16 ​

U16

Unsigned, 2 bytes (code 1).

U32 ​

U32

Unsigned, 4 bytes (code 2).

U64 ​

U64

Unsigned, 8 bytes (code 3).

I8 ​

I8

Signed, 1 byte (code 4).

I16 ​

I16

Signed, 2 bytes (code 5).

I32 ​

I32

Signed, 4 bytes (code 6).

I64 ​

I64

Signed, 8 bytes (code 7).

F32 ​

F32

IEEE binary32, 4 bytes (code 8).

F64 ​

F64

IEEE binary64, 8 bytes (code 9).

Member index ​

2 of 2 members

  • widthBytes of one stored value: 1, 2, 4 or 8.
  • f32One little-endian value as f32 .

Methods and associated constants ​

width ​

pub fn width(self) -> usize

Bytes of one stored value: 1, 2, 4 or 8.

f32 ​

pub fn f32(self, b: &[u8]) -> f32

One little-endian value as f32.

Reads the first Dtype::width bytes of b and converts, so integers lose precision above 2^24 and F64 rounds; b must hold that many bytes.

Implemented traits ​

impl Clone for Dtype
impl Debug for Dtype
impl PartialEq for Dtype

Contract reference ​

See the module reference for semantic input/output rules, units, allocation, mutation, failure behavior, and lifetime requirements. Declarations and documented members are synchronized from the crate source.

Definition