Expand description
SigMF sample datatypes (core:datatype).
A SigMF datatype string describes how each sample is stored in a
.sigmf-data file. It is composed of:
- a domain prefix:
rfor real orcfor complex (interleaved I/Q), - a component type:
f32,f64,i32,i16,u32,u16,i8, oru8, - for multi-byte components, an endianness suffix:
_leor_be.
Examples include cf32_le, ri16_be, and ru8. All 28 core datatypes
defined by the SigMF specification are supported; other strings are
rejected. Datatype stores the validated string and exposes its parts
through SampleDomain, ComponentType, Endianness, and
ByteType.
use sigmf::datatype::{ComponentType, Datatype, Endianness, SampleDomain};
use std::str::FromStr;
let datatype = Datatype::from_str("cf32_le")?;
assert!(datatype.is_complex());
assert_eq!(datatype.get_domain(), SampleDomain::Complex);
assert_eq!(datatype.get_dtype(), Some(ComponentType::F32));
assert_eq!(datatype.get_endian(), Some(Endianness::LE));
assert_eq!(datatype.component_bytes(), 4);
assert_eq!(datatype.bytes_per_channel_sample(), 8);
assert_eq!(datatype.to_string(), "cf32_le");
assert!(Datatype::from_str("cf32").is_err()); // missing endiannessStructs§
- Datatype
- A validated SigMF
core:datatypevalue such ascf32_leorru8.
Enums§
- Byte
Type - Single-byte component type of a datatype.
- Component
Type - Multi-byte component type of a datatype.
- Endianness
- Byte order of a multi-byte component type.
- Sample
Domain - Whether samples are real-valued or complex-valued.