SharedAnyViews

Struct SharedAnyViews 

Source
pub struct SharedAnyViews<V>(/* private fields */);
Expand description

A reference-counted, type-erased container for Views collections. SharedAnyViews allows multiple owners to share access to the same views collection through reference counting.

Implementations§

Source§

impl<V> SharedAnyViews<V>

Source

pub fn new(contents: impl Views<View = V> + 'static) -> Self

Creates a new type-erased shared view collection from any type implementing the Views trait.

This function wraps the provided collection in a type-erased container using reference counting, allowing different view collection implementations to be used through a common interface with shared ownership.

§Parameters
  • contents - Any collection implementing the Views trait with the appropriate item type
§Returns

A new SharedAnyViews instance containing the provided collection

Trait Implementations§

Source§

impl<V> Clone for SharedAnyViews<V>

Source§

fn clone(&self) -> Self

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

impl<V> Debug for SharedAnyViews<V>

Source§

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

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

impl<V> From<AnyViews<V>> for SharedAnyViews<V>

Source§

fn from(value: AnyViews<V>) -> Self

Converts to this type from the input type.
Source§

impl<V: View> Views for SharedAnyViews<V>

Source§

type Id = SelfId<Id>

The type of unique identifier for items in the collection. Must implement Hash and Ord to ensure uniqueness and ordering.
Source§

type Guard = Box<dyn WatcherGuard>

The type of guard returned when registering a watcher.
Source§

type View = V

The view type that this collection produces for each element.
Source§

fn get_id(&self, index: usize) -> Option<Self::Id>

Returns the unique identifier for the item at the specified index, or None if out of bounds.
Source§

fn get_view(&self, index: usize) -> Option<Self::View>

Returns the view at the specified index, or None if the index is out of bounds.
Source§

fn len(&self) -> usize

Returns the number of items in the collection.
Source§

fn watch( &self, range: impl RangeBounds<usize>, watcher: impl for<'a> Fn(Context<&'a [Self::Id]>) + 'static, ) -> Self::Guard

Registers a watcher for changes in the specified range of the collection. Read more
Source§

fn is_empty(&self) -> bool

Returns true if the collection contains no elements.

Auto Trait Implementations§

§

impl<V> Freeze for SharedAnyViews<V>

§

impl<V> !RefUnwindSafe for SharedAnyViews<V>

§

impl<V> !Send for SharedAnyViews<V>

§

impl<V> !Sync for SharedAnyViews<V>

§

impl<V> Unpin for SharedAnyViews<V>

§

impl<V> !UnwindSafe for SharedAnyViews<V>

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

Source§

fn use_id<F, Id>(self, f: F) -> UseId<Self, F>
where F: Fn(&Self) -> Id, Id: Ord + Hash,

Wraps the value in a UseId with the provided identification function.
Source§

fn self_id(self) -> SelfId<Self>

Wraps the value in a SelfId, making the value serve as its own identifier.
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> 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.
Source§

impl<T> ViewsExt for T
where T: Views,

Source§

fn map<F, V>(self, f: F) -> Map<Self, F>
where Self: Sized, F: Fn(Self::View) -> V, V: View,

Transforms each view in the collection using the provided mapping function. Read more
Source§

fn erase(self) -> AnyViews<AnyView>
where Self: 'static + Sized,

Erases the specific type of the view collection, returning a type-erased AnyViews.