pub struct Limit<S, L>{ /* private fields */ }
Expand description
A VectorDiff
stream adapter that presents a limited view of the
underlying ObservableVector
s 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>
impl<S> Limit<S, EmptyLimitStream>
Sourcepub fn new(
initial_values: Vector<VectorDiffContainerStreamElement<S>>,
inner_stream: S,
limit: usize,
) -> (Vector<VectorDiffContainerStreamElement<S>>, Self)
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>
impl<S, L> Limit<S, L>
Sourcepub fn dynamic(
initial_values: Vector<VectorDiffContainerStreamElement<S>>,
inner_stream: S,
limit_stream: L,
) -> Self
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.
Sourcepub fn dynamic_with_initial_limit(
initial_values: Vector<VectorDiffContainerStreamElement<S>>,
inner_stream: S,
initial_limit: usize,
limit_stream: L,
) -> (Vector<VectorDiffContainerStreamElement<S>>, Self)
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.