eyeball_im_util::vector

Struct Limit

Source
pub struct Limit<S, L>{ /* private fields */ }
Expand description

A VectorDiff stream adapter that presents a limited view of the underlying ObservableVectors items.

For example, let S be a Stream<Item = VectorDiff>. The Vector represented by S can have any length, but one may want to virtually limit this Vector to a certain size. Then this Limit adapter is appropriate.

An internal buffered vector is kept so that the adapter knows which values can be added when the limit is increased, or when values are removed and new values must be inserted. This fact is important if the items of the Vector have a non-negligible size.

It’s okay to have a limit larger than the length of the observed Vector.

Implementations§

Source§

impl<S> Limit<S, EmptyLimitStream>

Source

pub fn new( initial_values: Vector<VectorDiffContainerStreamElement<S>>, inner_stream: S, limit: usize, ) -> (Vector<VectorDiffContainerStreamElement<S>>, Self)

Create a new Limit with the given (unlimited) initial values, stream of VectorDiff updates for those values, and a fixed limit.

Returns the truncated initial values as well as a stream of updates that ensure that the resulting vector never exceeds the given limit.

Source§

impl<S, L> Limit<S, L>
where S: Stream, S::Item: VectorDiffContainer, L: Stream<Item = usize>,

Source

pub fn dynamic( initial_values: Vector<VectorDiffContainerStreamElement<S>>, inner_stream: S, limit_stream: L, ) -> Self

Create a new Limit with the given (unlimited) initial values, stream of VectorDiff updates for those values, and a stream of limits.

This is equivalent to dynamic_with_initial_limit where the initial_limit is 0, except that it doesn’t return the limited vector as it would be empty anyways.

Note that the returned Limit won’t produce anything until the first limit is produced by the limit stream.

Source

pub fn dynamic_with_initial_limit( initial_values: Vector<VectorDiffContainerStreamElement<S>>, inner_stream: S, initial_limit: usize, limit_stream: L, ) -> (Vector<VectorDiffContainerStreamElement<S>>, Self)

Create a new Limit with the given (unlimited) initial values, stream of VectorDiff updates for those values, and an initial limit as well as a stream of new limits.

Trait Implementations§

Source§

impl<S, L> Stream for Limit<S, L>
where S: Stream, S::Item: VectorDiffContainer, L: Stream<Item = usize>,

Source§

type Item = <S as Stream>::Item

Values yielded by the stream.
Source§

fn poll_next( self: Pin<&mut Self>, cx: &mut Context<'_>, ) -> Poll<Option<Self::Item>>

Attempt to pull out the next value of this stream, registering the current task for wakeup if the value is not yet available, and returning None if the stream is exhausted. Read more
Source§

fn size_hint(&self) -> (usize, Option<usize>)

Returns the bounds on the remaining length of the stream. Read more
Source§

impl<'__pin, S, L> Unpin for Limit<S, L>
where PinnedFieldsOf<__Origin<'__pin, S, L>>: Unpin, S: Stream, S::Item: VectorDiffContainer,

Source§

impl<S, L> VectorObserver<<<S as Stream>::Item as VectorDiffContainer>::Element> for Limit<S, L>
where S: Stream, S::Item: VectorDiffContainer, L: Stream<Item = usize>,

Auto Trait Implementations§

§

impl<S, L> Freeze for Limit<S, L>
where <S as Stream>::Item: Sized, S: Freeze, L: Freeze, <<S as Stream>::Item as VectorDiffContainerOps<<<S as Stream>::Item as VectorDiffContainer>::Element>>::LimitBuf: Freeze,

§

impl<S, L> RefUnwindSafe for Limit<S, L>
where <S as Stream>::Item: Sized, S: RefUnwindSafe, L: RefUnwindSafe, <<S as Stream>::Item as VectorDiffContainerOps<<<S as Stream>::Item as VectorDiffContainer>::Element>>::LimitBuf: RefUnwindSafe, <<S as Stream>::Item as VectorDiffContainer>::Element: RefUnwindSafe,

§

impl<S, L> Send for Limit<S, L>
where <S as Stream>::Item: Sized, S: Send, L: Send, <<S as Stream>::Item as VectorDiffContainerOps<<<S as Stream>::Item as VectorDiffContainer>::Element>>::LimitBuf: Send, <<S as Stream>::Item as VectorDiffContainer>::Element: Send + Sync,

§

impl<S, L> Sync for Limit<S, L>
where <S as Stream>::Item: Sized, S: Sync, L: Sync, <<S as Stream>::Item as VectorDiffContainerOps<<<S as Stream>::Item as VectorDiffContainer>::Element>>::LimitBuf: Sync, <<S as Stream>::Item as VectorDiffContainer>::Element: Sync + Send,

§

impl<S, L> UnwindSafe for Limit<S, L>
where <S as Stream>::Item: Sized, S: UnwindSafe, L: UnwindSafe, <<S as Stream>::Item as VectorDiffContainerOps<<<S as Stream>::Item as VectorDiffContainer>::Element>>::LimitBuf: UnwindSafe, <<S as Stream>::Item as VectorDiffContainer>::Element: UnwindSafe + RefUnwindSafe,

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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

impl<S, T, E> TryStream for S
where S: Stream<Item = Result<T, E>> + ?Sized,

Source§

type Ok = T

The type of successful values yielded by this future
Source§

type Error = E

The type of failures yielded by this future
Source§

fn try_poll_next( self: Pin<&mut S>, cx: &mut Context<'_>, ) -> Poll<Option<Result<<S as TryStream>::Ok, <S as TryStream>::Error>>>

Poll this TryStream as if it were a Stream. Read more
Source§

impl<T> WithSubscriber for T

Source§

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

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more