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 geolocation(&self) -> Option<GeoJsonPoint>
pub fn geolocation(&self) -> Option<GeoJsonPoint>
Gives the value of the geolocation 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 set_geolocation(&mut self, geolocation: GeoJsonPoint)
pub fn set_geolocation(&mut self, geolocation: GeoJsonPoint)
Sets the value of the geolocation field.
Sourcepub fn remove_geolocation(&mut self)
pub fn remove_geolocation(&mut self)
Removes the geolocation field.
Sourcepub fn set_geolocation_optional(&mut self, geolocation: Option<GeoJsonPoint>)
pub fn set_geolocation_optional(&mut self, geolocation: Option<GeoJsonPoint>)
Sets or removes the value of the geolocation field.
If geolocation is Some, then the value of the geolocation field is
set. Otherwise, the value is cleared.
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.
Trait Implementations§
impl StructuralPartialEq for Metadata
Auto Trait Implementations§
impl Freeze for Metadata
impl RefUnwindSafe for Metadata
impl Send for Metadata
impl Sync for Metadata
impl Unpin for Metadata
impl UnwindSafe for Metadata
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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