Skip to main content

Global

Struct Global 

Source
pub struct Global {
Show 19 fields pub version: String, pub datatype: Datatype, pub sample_rate: Option<Number>, pub author: Option<String>, pub collection: Option<String>, pub data_doi: Option<String>, pub description: Option<String>, pub hw: Option<String>, pub license: Option<String>, pub metadata_only: Option<bool>, pub meta_doi: Option<String>, pub num_channels: Option<Integer>, pub offset: Option<Integer>, pub recorder: Option<String>, pub sha512: Option<String>, pub geolocation: Option<GeoJson>, pub extensions: Option<Vec<ExtensionDeclaration>>, pub dataset: Option<String>, pub trailing_bytes: Option<Integer>, /* private fields */
}
Expand description

The SigMF global object of a metadata file.

Required fields (core:version and core:datatype) are stored directly; optional core fields are stored as Options and are omitted from serialized JSON when None. Unknown keys encountered during deserialization (typically extension fields) are retained and serialized back out unchanged; see Global::extra_fields and Global::insert_extra.

§Examples

use sigmf::global::{Datatype, Global};

let datatype: Datatype = "cf32_le".parse()?;
let mut global = Global::new("1.2.6", datatype);
global.set_sample_rate(1_000_000.0);
global.set_description("Example capture".to_string());

let json = serde_json::to_value(&global)?;
assert_eq!(json["core:version"], "1.2.6");
assert_eq!(json["core:datatype"], "cf32_le");
assert_eq!(json["core:sample_rate"], 1_000_000.0);
assert!(json.get("core:author").is_none());

Fields§

§version: String

Version of the SigMF specification the metadata conforms to (core:version).

§datatype: Datatype

Format of the samples stored in the dataset file (core:datatype).

§sample_rate: Option<Number>

Sample rate of the recording in samples per second (core:sample_rate).

§author: Option<String>

Name and optionally email address of the recording’s author (core:author).

§collection: Option<String>

Base filename of the SigMF collection this recording belongs to (core:collection).

§data_doi: Option<String>

Digital Object Identifier (DOI) of the dataset file (core:data_doi).

§description: Option<String>

Free-text description of the recording (core:description).

§hw: Option<String>

Description of the hardware used to make the recording (core:hw).

§license: Option<String>

URL of the license under which the recording is distributed (core:license).

§metadata_only: Option<bool>

Whether the metadata is intentionally distributed without a dataset file (core:metadata_only).

Must not be used together with Non-Conforming Dataset fields.

§meta_doi: Option<String>

Digital Object Identifier (DOI) of the metadata file (core:meta_doi).

§num_channels: Option<Integer>

Number of interleaved channels in the dataset file (core:num_channels).

The SigMF specification treats an absent value as one channel.

§offset: Option<Integer>

Index offset of the first sample in the dataset file (core:offset).

§recorder: Option<String>

Name of the software used to make the recording (core:recorder).

§sha512: Option<String>

Hex-encoded SHA-512 hash of the dataset file (core:sha512).

§geolocation: Option<GeoJson>

GeoJSON location of the recording system (core:geolocation).

§extensions: Option<Vec<ExtensionDeclaration>>

Extensions used by this recording’s metadata (core:extensions).

§dataset: Option<String>

Full filename of a Non-Conforming Dataset file (core:dataset).

§trailing_bytes: Option<Integer>

Number of bytes to ignore at the end of a Non-Conforming Dataset file (core:trailing_bytes).

Implementations§

Source§

impl Global

Source

pub fn new(version: impl Into<String>, datatype: Datatype) -> Self

Creates a Global with the required core:version and core:datatype fields set and every optional field unset.

No validation of version is performed here.

§Examples
use sigmf::global::{ComponentType, Datatype, Endianness, Global, SampleDomain};

let datatype = Datatype::new(
    SampleDomain::Complex,
    Some(ComponentType::I16),
    Some(Endianness::LE),
    None,
)?;
let global = Global::new("1.2.6", datatype);
assert_eq!(global.get_version(), "1.2.6");
assert_eq!(global.get_datatype().as_str(), "ci16_le");
assert!(global.get_sample_rate().is_none());
assert!(global.extra_fields().is_empty());
Source

pub fn extra_fields(&self) -> &Map<String, Value>

Returns the fields of this object that are not modeled by a typed field, keyed by their full JSON key.

These are the keys that did not map to a typed field during deserialization (typically extension fields such as antenna:gain), plus any added via Global::insert_extra. They are serialized alongside the typed core fields.

Source

pub fn insert_extra( &mut self, key: impl Into<String>, value: Value, ) -> Result<Option<Value>, SigmfError>

Inserts or replaces an extra (non-typed) field, returning the previous value for key if one was present.

The key is stored as given; namespace syntax and extension declarations are not checked here (see crate::validation).

§Errors

Returns SigmfError::InvalidMetadata if key is one of the core: global keys modeled by a typed field on Global (for example core:sample_rate); set those through the corresponding field or setter instead.

Source

pub fn set_version(&mut self, version: String)

Sets the SigMF specification version (core:version).

Source

pub fn set_datatype(&mut self, datatype: Datatype)

Sets the sample format of the dataset (core:datatype).

Source

pub fn set_sample_rate(&mut self, sample_rate: Number)

Sets the sample rate in samples per second (core:sample_rate).

Source

pub fn set_author(&mut self, author: String)

Sets the recording author (core:author).

Source

pub fn set_collection(&mut self, collection_str: String)

Sets the base filename of the associated collection (core:collection).

Source

pub fn set_data_doi(&mut self, data_doi: String)

Sets the DOI of the dataset file (core:data_doi).

Source

pub fn set_description(&mut self, description: String)

Sets the free-text description (core:description).

Source

pub fn set_hw(&mut self, hw: String)

Sets the hardware description (core:hw).

Source

pub fn set_license(&mut self, license: String)

Sets the license URL (core:license).

Source

pub fn set_metadata_only(&mut self, metadata_only: bool)

Sets whether the metadata is distributed without a dataset (core:metadata_only).

Source

pub fn set_meta_doi(&mut self, meta_doi: String)

Sets the DOI of the metadata file (core:meta_doi).

Source

pub fn set_num_channels(&mut self, num_channels: Integer)

Sets the number of interleaved channels (core:num_channels).

Source

pub fn set_offset(&mut self, offset: Integer)

Sets the index offset of the first sample (core:offset).

Source

pub fn set_recorder(&mut self, recorder: String)

Sets the name of the recording software (core:recorder).

Source

pub fn set_sha512(&mut self, hash: String)

Sets the SHA-512 hash of the dataset file (core:sha512).

The value is stored as given; it is not computed or verified here.

Source

pub fn set_geolocation(&mut self, geolocation: GeoJson)

Sets the GeoJSON location of the recording system (core:geolocation).

Source

pub fn set_extensions(&mut self, extensions: Vec<ExtensionDeclaration>)

Replaces the list of declared extensions (core:extensions).

Source

pub fn set_dataset(&mut self, dataset: String)

Sets the Non-Conforming Dataset filename (core:dataset).

Source

pub fn set_trailing_bytes(&mut self, trailing_bytes: Integer)

Sets the number of trailing bytes to ignore in a Non-Conforming Dataset (core:trailing_bytes).

Source

pub fn get_version(&self) -> String

Returns a copy of the SigMF specification version (core:version).

Source

pub fn get_datatype(&self) -> Datatype

Returns a copy of the dataset sample format (core:datatype).

Source

pub fn get_sample_rate(&self) -> Option<Number>

Returns the sample rate in samples per second (core:sample_rate), if set.

Source

pub fn get_author(&self) -> Option<String>

Returns a copy of the recording author (core:author), if set.

Source

pub fn get_collection(&self) -> Option<String>

Returns a copy of the associated collection’s base filename (core:collection), if set.

Source

pub fn get_data_doi(&self) -> Option<String>

Returns a copy of the dataset DOI (core:data_doi), if set.

Source

pub fn get_description(&self) -> Option<String>

Returns a copy of the free-text description (core:description), if set.

Source

pub fn get_hw(&self) -> Option<String>

Returns a copy of the hardware description (core:hw), if set.

Source

pub fn get_license(&self) -> Option<String>

Returns a copy of the license URL (core:license), if set.

Source

pub fn get_metadata_only(&self) -> Option<bool>

Returns the metadata-only flag (core:metadata_only), if set.

Source

pub fn get_meta_doi(&self) -> Option<String>

Returns a copy of the metadata DOI (core:meta_doi), if set.

Source

pub fn get_num_channels(&self) -> Option<Integer>

Returns the number of interleaved channels (core:num_channels), if set.

This returns None when the key is absent; it does not apply the specification’s default of one channel.

Source

pub fn get_offset(&self) -> Option<Integer>

Returns the index offset of the first sample (core:offset), if set.

Source

pub fn get_recorder(&self) -> Option<String>

Returns a copy of the recording software name (core:recorder), if set.

Source

pub fn get_sha512(&self) -> Option<String>

Returns a copy of the dataset SHA-512 hash (core:sha512), if set.

Source

pub fn get_geolocation(&self) -> Option<GeoJson>

Returns a copy of the GeoJSON location (core:geolocation), if set.

Source

pub fn get_extensions(&self) -> Option<Vec<ExtensionDeclaration>>

Returns a copy of the declared extensions (core:extensions), if set.

Source

pub fn get_dataset(&self) -> Option<String>

Returns a copy of the Non-Conforming Dataset filename (core:dataset), if set.

Source

pub fn get_trailing_bytes(&self) -> Option<Integer>

Returns the number of trailing bytes to ignore (core:trailing_bytes), if set.

Trait Implementations§

Source§

impl Clone for Global

Source§

fn clone(&self) -> Global

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Global

Source§

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

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

impl<'de> Deserialize<'de> for Global

Source§

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

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

impl Serialize for Global

Source§

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

Serialize this value into the given Serde serializer. Read more

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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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

Source§

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

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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
§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

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

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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