df2

Struct Segment

Source
pub struct Segment {
    pub data: Vec<u16>,
    pub time_interval: u16,
}
Expand description

A waveform segment.

Fields§

§data: Vec<u16>

The waveform samples.

§time_interval: u16

The time interval, in cycles.

Implementations§

Source§

impl Segment

Source

pub fn from_path<P: AsRef<Path>>(path: P) -> Result<Segment>

Reads a Segment from a path.

§Examples
use df2::Segment;
let segment = Segment::from_path("data/one-segment.bin").unwrap();
Source

pub fn from_read<R: Read>(read: &mut R) -> Result<Segment>

Reads a Segment from a Read.

§Examples
use std::fs::File;
use df2::Segment;
let mut file = File::open("data/one-segment.bin").unwrap();
let segment = Segment::from_read(&mut file).unwrap();
Source

pub fn len(&self) -> u16

Returns the length of this segment in bytes.

§Examples
let segment = Segment::from_path("data/one-segment.bin").unwrap();
assert_eq!(110, segment.len());
Source

pub fn is_empty(&self) -> bool

Returns true if this segment has no data.

§Examples
let segment = Segment { data: Vec::new(), time_interval: 0 };
assert!(segment.is_empty());
let segment = Segment::from_path("data/one-segment.bin").unwrap();
assert!(!segment.is_empty());

Trait Implementations§

Source§

impl Debug for Segment

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Encodable for Segment

Source§

fn encode<__S: Encoder>(&self, s: &mut __S) -> Result<(), __S::Error>

Serialize a value using an Encoder.
Source§

impl PartialEq for Segment

Source§

fn eq(&self, other: &Segment) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Segment

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
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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