Skip to main content

Recording

Struct Recording 

Source
pub struct Recording { /* private fields */ }
Expand description

An open plain SigMF recording: parsed metadata plus a handle to its dataset file.

See the module documentation for how sample indices are mapped to dataset bytes, and RecordingWriter for an example.

Implementations§

Source§

impl Recording

Source

pub fn open(path: impl AsRef<Path>) -> Result<Self, SigmfError>

Opens the recording described by the .sigmf-meta file at path and its dataset.

The dataset is the file named by core:dataset in the same directory as path or, when that is absent, path with its extension replaced by sigmf-data. For core:metadata_only recordings the dataset is opened only if core:dataset names an existing file; otherwise sample access returns SigmfError::NoDataset.

§Errors

Returns an error if the metadata cannot be read or parsed, SigmfError::InvalidMetadata if core:dataset is not a plain filename, or SigmfError::Io if the dataset cannot be opened.

Source

pub fn open_metadata_only(path: impl AsRef<Path>) -> Result<Self, SigmfError>

Opens only the metadata at path, without opening any dataset.

Methods that access samples return SigmfError::NoDataset.

§Errors

Returns an error if the metadata cannot be read or parsed, or SigmfError::InvalidMetadata if core:dataset is not a plain filename.

Source

pub fn metadata(&self) -> &Metadata

Returns the parsed metadata.

Source

pub fn metadata_path(&self) -> &Path

Returns the path the metadata was opened from.

Source

pub fn dataset_path(&self) -> Option<&Path>

Returns the path of the opened dataset, or None if no dataset was opened.

Source

pub fn first_sample_index(&self) -> Integer

Returns the absolute sample index of the first frame in the dataset: core:offset, or zero when it is omitted.

Source

pub fn frame_count(&self) -> Result<Integer, SigmfError>

Returns the number of frames stored in the dataset.

Capture header bytes and trailing bytes are excluded. Valid absolute sample indices are first_sample_index()..first_sample_index() + frame_count().

§Errors

Returns SigmfError::NoDataset if no dataset is open, SigmfError::UnsupportedLayout if header or trailing bytes do not fit in the dataset, or SigmfError::InvalidMetadata if the remaining bytes are not a whole number of frames.

Source

pub fn dataset_digest(&mut self) -> Result<String, SigmfError>

Computes the SHA-512 digest of the entire dataset file, including any header and trailing bytes, as a lowercase hexadecimal string.

§Errors

Returns SigmfError::NoDataset if no dataset is open, or SigmfError::Io if reading fails.

Source

pub fn verify_dataset_digest(&mut self) -> Result<(), SigmfError>

Checks the dataset against the core:sha512 digest in the metadata.

The comparison ignores ASCII case.

§Errors

Returns SigmfError::InvalidMetadata if core:sha512 is absent, SigmfError::HashMismatch if the digests differ, or any error from dataset_digest.

Source

pub fn read_frames( &mut self, start: Integer, count: Integer, ) -> Result<Vec<SampleValue>, SigmfError>

Reads count frames starting at absolute sample index start.

The stored dataset begins at first_sample_index (core:offset, or zero when omitted). Capture header bytes are skipped. The result holds count * core:num_channels samples in on-disk order and is read into memory at once; use frame_blocks for large ranges.

§Errors

Returns SigmfError::InvalidRange if the range starts before the first sample or extends past the last frame, SigmfError::ResourceLimit if the block does not fit in memory, or any error from frame_count, decoding, or I/O.

Source

pub fn frame_blocks( &mut self, start: Integer, count: Integer, block_frames: Integer, ) -> Result<FrameBlocks<'_>, SigmfError>

Returns an iterator that reads count frames starting at absolute sample index start, in blocks of at most block_frames frames.

The whole range is validated up front. Each item is the result of read_frames for one block; the iterator stops after the first error.

§Errors

Returns SigmfError::InvalidRange if block_frames is zero or the range lies outside the dataset, or any error from frame_count.

Source

pub fn crop_to( &mut self, metadata_path: impl AsRef<Path>, sample_start: Integer, sample_count: Integer, block_frames: Integer, extension_handler: Option<&mut dyn CropExtensionHandler>, ) -> Result<String, SigmfError>

Writes frames sample_start..sample_start + sample_count (absolute indices) to a new plain recording at metadata_path, returning the new dataset’s SHA-512 digest.

Absolute sample indices are preserved: the output’s core:offset is sample_start, and captures and annotations are clipped to the cropped range without being renumbered. core:dataset is cleared, so the output dataset is named after metadata_path, and core:sha512 is recomputed. Input NCD headers and trailing bytes are omitted from the output. Samples are copied in blocks of block_frames frames, and the output is published as described for RecordingWriter.

If extension fields are present, extension_handler must define their crop semantics; otherwise the operation fails rather than silently misaligning application-defined coordinates.

§Errors

Returns SigmfError::InvalidRange if block_frames is zero or the range lies outside the dataset, SigmfError::InvalidMetadata if extension fields cannot be cropped, or any error from reading frames, RecordingWriter::new, or RecordingWriter::finish.

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