Skip to main content

Series

Struct Series 

pub struct Series<T> { /* private fields */ }
Expand description

A bar-aligned series of values.

Internally this is backed by a VecDeque and is used to represent Pine-like series variables (one value per bar). You don’t construct Series directly; it is returned by visual primitives like Plot.

§Examples

use navi_types::Series;

// Series is typically constructed internally; here we use from_queue for testing.
let mut s: Series<f64> = Series::from_queue(vec![1.0, 2.0, 3.0].into());
assert_eq!(s.len(), 3);
assert_eq!(s.get(0), Some(&1.0));
assert_eq!(s.last(), Some(&3.0));

for val in &s {
    let _ = *val;
}

Implementations§

§

impl<T> Series<T>

pub fn from_queue(queue: VecDeque<T>) -> Series<T>

Creates a Series from an existing VecDeque.

pub fn iter(&self) -> Iter<'_, T>

Returns an iterator over references to the elements.

§

impl<T> Series<T>
where T: Default,

pub fn new() -> Series<T>

Creates an empty series.

pub fn update(&mut self, value: T)

Updates the last element in the series.

§Panics

Panics if the series is empty.

pub fn truncate(&mut self, length: usize) -> usize

Removes elements from the front to keep at most length elements. Returns the number of elements removed.

pub fn append_new(&mut self)

Appends a new default-initialized element.

pub fn get(&self, index: usize) -> Option<&T>

Returns the value at index, or None if out of bounds.

pub fn len(&self) -> usize

Returns the number of elements in the series.

pub fn is_empty(&self) -> bool

Returns true if the series contains no elements.

pub fn last(&self) -> Option<&T>

Returns the last element in the series, or None if empty.

Trait Implementations§

§

impl<T> Clone for Series<T>
where T: Clone,

§

fn clone(&self) -> Series<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
§

impl<T> Debug for Series<T>
where T: Debug,

§

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

Formats the value using the given formatter. Read more
§

impl<T> Default for Series<T>
where T: Default,

§

fn default() -> Series<T>

Returns the “default value” for a type. Read more
§

impl<'de, T> Deserialize<'de> for Series<T>
where T: Deserialize<'de>,

§

fn deserialize<D>( deserializer: D, ) -> Result<Series<T>, <D as Deserializer<'de>>::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
§

impl<T> Index<usize> for Series<T>

§

type Output = T

The returned type after indexing.
§

fn index(&self, index: usize) -> &<Series<T> as Index<usize>>::Output

Performs the indexing (container[index]) operation. Read more
§

impl<'a, T> IntoIterator for &'a Series<T>

§

type Item = &'a T

The type of the elements being iterated over.
§

type IntoIter = Iter<'a, T>

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> <&'a Series<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
§

impl<T> IntoIterator for Series<T>

§

type Item = T

The type of the elements being iterated over.
§

type IntoIter = IntoIter<T>

Which kind of iterator are we turning this into?
§

fn into_iter(self) -> <Series<T> as IntoIterator>::IntoIter

Creates an iterator from a value. Read more
§

impl<T> Serialize for Series<T>
where T: Serialize,

§

fn serialize<S>( &self, serializer: S, ) -> Result<<S as Serializer>::Ok, <S as Serializer>::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<T> Freeze for Series<T>

§

impl<T> RefUnwindSafe for Series<T>
where T: RefUnwindSafe,

§

impl<T> Send for Series<T>
where T: Send,

§

impl<T> Sync for Series<T>
where T: Sync,

§

impl<T> Unpin for Series<T>
where T: Unpin,

§

impl<T> UnsafeUnpin for Series<T>

§

impl<T> UnwindSafe for Series<T>
where T: UnwindSafe,

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> 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
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,