Skip to main content

HandlerList

Struct HandlerList 

Source
pub struct HandlerList<F>
where F: ?Sized,
{ /* private fields */ }
Expand description

A list of event handlers that tolerates being modified while it is being invoked: invocation works on a snapshot, and the snapshot is only copied when the list actually changes.

Implementations§

Source§

impl<F> HandlerList<F>
where F: ?Sized,

Source

pub fn new() -> HandlerList<F>

Source

pub fn with_shared_ids(ids: Rc<Cell<u64>>) -> HandlerList<F>

A list whose tokens come from ids, a counter shared with other lists: tokens across all of them increase in subscription order.

Source

pub fn with_ordered_ids() -> HandlerList<F>

A list whose tokens come from the counter of the process, which every list made this way shares: tokens across all of them increase in subscription order, as with with_shared_ids, without a counter to allocate.

Source

pub fn is_empty(&self) -> bool

Source

pub fn len(&self) -> usize

Source

pub fn add(&self, handler: Rc<F>) -> u64

Adds a handler and returns a token that removes it again.

Source

pub fn remove(&self, token: u64) -> bool

Removes the handler registered under token.

Source

pub fn snapshot(&self) -> HandlerSnapshot<F>

Returns the current handlers; later modifications do not affect it.

Trait Implementations§

Source§

impl<F> Default for HandlerList<F>
where F: ?Sized,

Source§

fn default() -> HandlerList<F>

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

Auto Trait Implementations§

§

impl<F> !Freeze for HandlerList<F>

§

impl<F> !RefUnwindSafe for HandlerList<F>

§

impl<F> !Send for HandlerList<F>

§

impl<F> !Sync for HandlerList<F>

§

impl<F> !UnwindSafe for HandlerList<F>

§

impl<F> Unpin for HandlerList<F>
where RefCell<Option<Rc<SmallVec<[(u64, Rc<F>); 2]>>>>: Unpin, F: ?Sized,

§

impl<F> UnsafeUnpin for HandlerList<F>
where RefCell<Option<Rc<SmallVec<[(u64, Rc<F>); 2]>>>>: UnsafeUnpin, F: ?Sized,

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> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.