pub struct Estimate<V, S: Spread> { /* private fields */ }Expand description
A value with its confidence. The value is present exactly when the confidence is an estimate.
use sound_to_patch::confidence::{Estimate, Level, Reason, ReasonCode, Signal};
use sound_to_patch::units::Hz;
let frames = Reason::new(ReasonCode::ActiveFrames, Signal::Count(412))?;
let centroid = Estimate::new(Hz::new(1520.0)?, Level::High, Some(Hz::new(310.0)?), vec![frames])?;
assert_eq!(centroid.value().map(|hz| hz.get()), Some(1520.0));
let silent = Reason::new(ReasonCode::SilentStem, Signal::Flag(true))?;
let none = Estimate::<Hz, Hz>::none(vec![silent])?;
assert!(none.value().is_none());Implementations§
Source§impl<V, S: Spread> Estimate<V, S>
impl<V, S: Spread> Estimate<V, S>
Sourcepub fn new(
value: V,
level: Level,
spread: Option<S>,
reasons: Vec<Reason>,
) -> Result<Self, ConfidenceError>
pub fn new( value: V, level: Level, spread: Option<S>, reasons: Vec<Reason>, ) -> Result<Self, ConfidenceError>
A value with the confidence of an estimate.
§Errors
Returns a ConfidenceError as Confidence::estimate does.
Sourcepub fn confidence(&self) -> &Confidence<S>
pub fn confidence(&self) -> &Confidence<S>
Returns the confidence.
Trait Implementations§
impl<V: PartialEq, S: PartialEq + Spread> StructuralPartialEq for Estimate<V, S>
Auto Trait Implementations§
impl<V, S> Freeze for Estimate<V, S>
impl<V, S> RefUnwindSafe for Estimate<V, S>where
V: RefUnwindSafe,
S: RefUnwindSafe,
impl<V, S> Send for Estimate<V, S>
impl<V, S> Sync for Estimate<V, S>
impl<V, S> Unpin for Estimate<V, S>
impl<V, S> UnsafeUnpin for Estimate<V, S>where
V: UnsafeUnpin,
S: UnsafeUnpin,
impl<V, S> UnwindSafe for Estimate<V, S>where
V: UnwindSafe,
S: UnwindSafe,
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
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
impl<T> CloneAny for T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Converts
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Converts
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Converts
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Converts
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.§impl<T> DowncastSend for T
impl<T> DowncastSend for T
§impl<T> DowncastSync for T
impl<T> DowncastSync for T
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> ⓘ
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 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> ⓘ
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