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: StringVersion of the SigMF specification the metadata conforms to (core:version).
datatype: DatatypeFormat 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).
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
impl Global
Sourcepub fn new(version: impl Into<String>, datatype: Datatype) -> Self
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());Sourcepub fn extra_fields(&self) -> &Map<String, Value>
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.
Sourcepub fn insert_extra(
&mut self,
key: impl Into<String>,
value: Value,
) -> Result<Option<Value>, SigmfError>
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.
Sourcepub fn set_version(&mut self, version: String)
pub fn set_version(&mut self, version: String)
Sets the SigMF specification version (core:version).
Sourcepub fn set_datatype(&mut self, datatype: Datatype)
pub fn set_datatype(&mut self, datatype: Datatype)
Sets the sample format of the dataset (core:datatype).
Sourcepub fn set_sample_rate(&mut self, sample_rate: Number)
pub fn set_sample_rate(&mut self, sample_rate: Number)
Sets the sample rate in samples per second (core:sample_rate).
Sets the recording author (core:author).
Sourcepub fn set_collection(&mut self, collection_str: String)
pub fn set_collection(&mut self, collection_str: String)
Sets the base filename of the associated collection (core:collection).
Sourcepub fn set_data_doi(&mut self, data_doi: String)
pub fn set_data_doi(&mut self, data_doi: String)
Sets the DOI of the dataset file (core:data_doi).
Sourcepub fn set_description(&mut self, description: String)
pub fn set_description(&mut self, description: String)
Sets the free-text description (core:description).
Sourcepub fn set_license(&mut self, license: String)
pub fn set_license(&mut self, license: String)
Sets the license URL (core:license).
Sourcepub fn set_metadata_only(&mut self, metadata_only: bool)
pub fn set_metadata_only(&mut self, metadata_only: bool)
Sets whether the metadata is distributed without a dataset (core:metadata_only).
Sourcepub fn set_meta_doi(&mut self, meta_doi: String)
pub fn set_meta_doi(&mut self, meta_doi: String)
Sets the DOI of the metadata file (core:meta_doi).
Sourcepub fn set_num_channels(&mut self, num_channels: Integer)
pub fn set_num_channels(&mut self, num_channels: Integer)
Sets the number of interleaved channels (core:num_channels).
Sourcepub fn set_offset(&mut self, offset: Integer)
pub fn set_offset(&mut self, offset: Integer)
Sets the index offset of the first sample (core:offset).
Sourcepub fn set_recorder(&mut self, recorder: String)
pub fn set_recorder(&mut self, recorder: String)
Sets the name of the recording software (core:recorder).
Sourcepub fn set_sha512(&mut self, hash: String)
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.
Sourcepub fn set_geolocation(&mut self, geolocation: GeoJson)
pub fn set_geolocation(&mut self, geolocation: GeoJson)
Sets the GeoJSON location of the recording system (core:geolocation).
Sourcepub fn set_extensions(&mut self, extensions: Vec<ExtensionDeclaration>)
pub fn set_extensions(&mut self, extensions: Vec<ExtensionDeclaration>)
Replaces the list of declared extensions (core:extensions).
Sourcepub fn set_dataset(&mut self, dataset: String)
pub fn set_dataset(&mut self, dataset: String)
Sets the Non-Conforming Dataset filename (core:dataset).
Sourcepub fn set_trailing_bytes(&mut self, trailing_bytes: Integer)
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).
Sourcepub fn get_version(&self) -> String
pub fn get_version(&self) -> String
Returns a copy of the SigMF specification version (core:version).
Sourcepub fn get_datatype(&self) -> Datatype
pub fn get_datatype(&self) -> Datatype
Returns a copy of the dataset sample format (core:datatype).
Sourcepub fn get_sample_rate(&self) -> Option<Number>
pub fn get_sample_rate(&self) -> Option<Number>
Returns the sample rate in samples per second (core:sample_rate), if set.
Returns a copy of the recording author (core:author), if set.
Sourcepub fn get_collection(&self) -> Option<String>
pub fn get_collection(&self) -> Option<String>
Returns a copy of the associated collection’s base filename (core:collection), if set.
Sourcepub fn get_data_doi(&self) -> Option<String>
pub fn get_data_doi(&self) -> Option<String>
Returns a copy of the dataset DOI (core:data_doi), if set.
Sourcepub fn get_description(&self) -> Option<String>
pub fn get_description(&self) -> Option<String>
Returns a copy of the free-text description (core:description), if set.
Sourcepub fn get_hw(&self) -> Option<String>
pub fn get_hw(&self) -> Option<String>
Returns a copy of the hardware description (core:hw), if set.
Sourcepub fn get_license(&self) -> Option<String>
pub fn get_license(&self) -> Option<String>
Returns a copy of the license URL (core:license), if set.
Sourcepub fn get_metadata_only(&self) -> Option<bool>
pub fn get_metadata_only(&self) -> Option<bool>
Returns the metadata-only flag (core:metadata_only), if set.
Sourcepub fn get_meta_doi(&self) -> Option<String>
pub fn get_meta_doi(&self) -> Option<String>
Returns a copy of the metadata DOI (core:meta_doi), if set.
Sourcepub fn get_num_channels(&self) -> Option<Integer>
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.
Sourcepub fn get_offset(&self) -> Option<Integer>
pub fn get_offset(&self) -> Option<Integer>
Returns the index offset of the first sample (core:offset), if set.
Sourcepub fn get_recorder(&self) -> Option<String>
pub fn get_recorder(&self) -> Option<String>
Returns a copy of the recording software name (core:recorder), if set.
Sourcepub fn get_sha512(&self) -> Option<String>
pub fn get_sha512(&self) -> Option<String>
Returns a copy of the dataset SHA-512 hash (core:sha512), if set.
Sourcepub fn get_geolocation(&self) -> Option<GeoJson>
pub fn get_geolocation(&self) -> Option<GeoJson>
Returns a copy of the GeoJSON location (core:geolocation), if set.
Sourcepub fn get_extensions(&self) -> Option<Vec<ExtensionDeclaration>>
pub fn get_extensions(&self) -> Option<Vec<ExtensionDeclaration>>
Returns a copy of the declared extensions (core:extensions), if set.
Sourcepub fn get_dataset(&self) -> Option<String>
pub fn get_dataset(&self) -> Option<String>
Returns a copy of the Non-Conforming Dataset filename (core:dataset), if set.
Sourcepub fn get_trailing_bytes(&self) -> Option<Integer>
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<'de> Deserialize<'de> for Global
impl<'de> Deserialize<'de> for Global
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Global
impl RefUnwindSafe for Global
impl Send for Global
impl Sync for Global
impl Unpin for Global
impl UnsafeUnpin for Global
impl UnwindSafe for Global
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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