[][src]Struct snec::Handle

pub struct Handle<'a, E: Entry, R: Receiver<E>> { /* fields omitted */ }

A handle to a config entry value which is being watched by a receiver.

Such handles not only have the semantics of managing a value for a specific field, they also automatically notify the receiver whenever the value changes.

Implementations

impl<'a, E: Entry, R: Receiver<E>> Handle<'a, E, R>[src]

pub fn new(target: &'a mut E::Data, receiver: R) -> Self[src]

Creates a handle pointing to the specified value and with the specified receiver.

pub fn set(&mut self, new_value: E::Data)[src]

Sets the handle's pointee to the specified value, notifying the receiver.

For large values where partial modification using a mutable reference would improve performance (Vec is a good example of such a type), modify or modify_with should be used instead.

pub fn modify<'b>(&'b mut self) -> ModificationScope<'a, 'b, E, R>[src]

Creates a ModificationScope for modifying the value inside without reallocating/moving and without a closure, while still notifying the receiver when modification is finished. The resulting ModificationScope acts like a mutable reference to the stored data, which allows direct modification.

modify_with may be used instead. For small values like integers, set might be faster.

pub fn modify_with<F>(&mut self, f: F) where
    F: FnMut(&mut E::Data), 
[src]

Modifies the handle's pointee using the specified closure, notifying the receiver.

modify may be used instead, for simplicity. For small values like integers, set might be faster.

pub fn set_silently(&mut self, new_value: E::Data)[src]

Sets the handle's pointee to the specified value without notifying the receiver. Doing this is heavily discouraged and should only be used in special cases.

For large values where partial modification using a mutable reference would improve performance (Vec is a good example of such a type), modify_silently or modify_silently_with should be used instead.

pub fn modify_silently(&mut self) -> &mut E::Data[src]

Returns a mutable reference to the handle's pointee. This will not notify any receiver, which is heavily discouraged and should only be used in special cases.

modify_silently_with may be used instead. For small values like integers, set_silently might be faster.

pub fn modify_silently_with<F>(&mut self, f: F) where
    F: FnMut(&mut E::Data), 
[src]

Modifies the handle's pointee using the specified closure, without notifying the receiver. Doing this is heavily discouraged and should only be used in special cases.

modify_silently may be used instead, for simplicity. For small values like integers, set_silently might be faster.

Trait Implementations

impl<'a, 'b, E, R> AsMut<Handle<'a, E, R>> for ModificationScope<'a, 'b, E, R> where
    E: Entry,
    R: Receiver<E>, 
[src]

impl<'a, 'b, E, R> AsRef<Handle<'a, E, R>> for ModificationScope<'a, 'b, E, R> where
    E: Entry,
    R: Receiver<E>, 
[src]

impl<'a, E, R> Debug for Handle<'a, E, R> where
    E: Entry,
    R: Receiver<E>,
    E::Data: Debug
[src]

impl<'a, E, R> Deref for Handle<'a, E, R> where
    E: Entry,
    R: Receiver<E>,
    E::Data: Deref
[src]

type Target = E::Data

The resulting type after dereferencing.

Auto Trait Implementations

impl<'a, E, R> RefUnwindSafe for Handle<'a, E, R> where
    E: RefUnwindSafe,
    R: RefUnwindSafe,
    <E as Entry>::Data: RefUnwindSafe

impl<'a, E, R> Send for Handle<'a, E, R> where
    E: Send,
    R: Send,
    <E as Entry>::Data: Send

impl<'a, E, R> Sync for Handle<'a, E, R> where
    E: Sync,
    R: Sync,
    <E as Entry>::Data: Sync

impl<'a, E, R> Unpin for Handle<'a, E, R> where
    E: Unpin,
    R: Unpin

impl<'a, E, R> !UnwindSafe for Handle<'a, E, R>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.