Struct maia_httpd::sigmf::Metadata
source · pub struct Metadata { /* private fields */ }
Expand description
SigMF metadata.
This structure can be used to create and edit SigMF metadata, and convert it
to JSON format for its storage in a .sigmf-meta
file.
§Examples
use maia_httpd::sigmf::{Datatype, Field, Metadata, SampleFormat};
let datatype = Datatype { field: Field::Complex, format: SampleFormat::I8 };
let sample_rate = 1e6; // 1 Msps
let frequency = 100e6; // 100 MHz
let metadata = Metadata::new(datatype, sample_rate, frequency);
println!("{}", metadata.to_json());
Implementations§
source§impl Metadata
impl Metadata
sourcepub fn new(datatype: Datatype, sample_rate: f64, frequency: f64) -> Metadata
pub fn new(datatype: Datatype, sample_rate: f64, frequency: f64) -> Metadata
Creates a new SigMF metadata object.
The datatype, sample rate and frequency are mandatory parameters. The datetime field is set to the current time. The description and author fields are initialized to empty strings.
sourcepub fn set_datatype(&mut self, datatype: Datatype)
pub fn set_datatype(&mut self, datatype: Datatype)
Sets the value datatype field.
sourcepub fn sample_rate(&self) -> f64
pub fn sample_rate(&self) -> f64
Gives the value of the sample rate field (in samples per second).
sourcepub fn set_sample_rate(&mut self, sample_rate: f64)
pub fn set_sample_rate(&mut self, sample_rate: f64)
Sets the value of the sample rate field.
sourcepub fn description(&self) -> &str
pub fn description(&self) -> &str
Gives the value of the description field.
sourcepub fn set_description(&mut self, description: &str)
pub fn set_description(&mut self, description: &str)
Sets the value of the description field.
Gives the value of the author field.
Sets the value of the author field.
sourcepub fn set_frequency(&mut self, frequency: f64)
pub fn set_frequency(&mut self, frequency: f64)
Sets the value of the frequency field.
sourcepub fn set_datetime(&mut self, datetime: DateTime<Utc>)
pub fn set_datetime(&mut self, datetime: DateTime<Utc>)
Sets the value of the datetime field.
sourcepub fn set_datetime_now(&mut self)
pub fn set_datetime_now(&mut self)
Sets the datetime field to the current time.
sourcepub fn to_json(&self) -> String
pub fn to_json(&self) -> String
Returns a string that represents the metadata in JSON.
The formatting of the JSON is compliant with the SigMF standard.
sourcepub fn to_json_value(&self) -> Value
pub fn to_json_value(&self) -> Value
Returns a JSON serde_json::Value
that represents the metadata in JSON.
The formatting of the JSON is compliant with the SigMF standard.