pub struct RecordingRef { /* private fields */ }Expand description
One entry of a SigMF collection’s core:streams array.
Identifies a recording by its base name (the metadata file name without
the .sigmf-meta extension) and the SHA-512 hash of that metadata file,
as a lowercase hexadecimal string.
Implementations§
Source§impl RecordingRef
impl RecordingRef
Sourcepub fn new(name: &str, hash: &str) -> Self
pub fn new(name: &str, hash: &str) -> Self
Creates a reference to the recording name whose metadata file has
SHA-512 digest hash.
Neither argument is validated. The reference has no extension fields and serializes as an object (not a legacy tuple).
§Examples
use sigmf::recording::RecordingRef;
let reference = RecordingRef::new("example", "0123abcd");
assert_eq!(reference.get_name(), "example");
assert_eq!(reference.get_hash(), "0123abcd");
let json = serde_json::to_value(&reference).unwrap();
assert_eq!(json, serde_json::json!({"name": "example", "hash": "0123abcd"}));Sourcepub fn get_hash(&self) -> &str
pub fn get_hash(&self) -> &str
Returns the SHA-512 digest of the recording’s metadata file (the
hash key).
Sourcepub fn extra_fields(&self) -> &Map<String, Value>
pub fn extra_fields(&self) -> &Map<String, Value>
Returns the extension fields preserved on this entry, i.e. every key
other than name and hash.
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 extension field on this entry.
Returns the previous value stored under key, if any. Note that a
reference parsed from a legacy [name, hash] tuple is written back as
a tuple by Collection::to_vec_preserving_stream_forms, which
drops any extension fields added to it.
§Errors
Returns crate::SigmfError::InvalidMetadata if key is name or
hash; use RecordingRef::set_name or RecordingRef::set_hash
instead.
Trait Implementations§
Source§impl Clone for RecordingRef
impl Clone for RecordingRef
Source§fn clone(&self) -> RecordingRef
fn clone(&self) -> RecordingRef
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for RecordingRef
impl Debug for RecordingRef
Source§impl<'de> Deserialize<'de> for RecordingRef
impl<'de> Deserialize<'de> for RecordingRef
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 RecordingRef
impl RefUnwindSafe for RecordingRef
impl Send for RecordingRef
impl Sync for RecordingRef
impl Unpin for RecordingRef
impl UnsafeUnpin for RecordingRef
impl UnwindSafe for RecordingRef
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