pub struct WatchHandler<T, ST> { /* private fields */ }
Expand description

Handler for hanging gets. The common way to use this is to implement the Sender trait for the FIDL responder that the handler is used for. There should be one instance of HangingGetHandler per interface per connection, as the handler needs to keep track of state per connection.

Implementations§

source§

impl<T, ST> WatchHandler<T, ST>
where T: Clone + PartialEq + 'static, ST: Sender<T> + 'static,

source

pub fn create(initial_value: Option<T>) -> Self

Creates a new instance of WatchHandler. If |initial_value| is provided, it will return immediately on first watch. Otherwise, the first watch returns when the value is set for the first time. Uses default change function which just checks for any change.

source§

impl<T, ST> WatchHandler<T, ST>
where T: Clone + 'static, ST: Sender<T> + 'static,

source

pub fn create_with_change_fn( change_function: Box<dyn Fn(&T, &T) -> bool + Send + Sync + 'static>, initial_value: Option<T> ) -> Self

Creates a new instance of WatchHandler. If |initial_value| is provided, it will return immediately on first watch. Otherwise, the first watch returns when the value is set for the first time.

source

pub fn watch(&mut self, responder: ST) -> Result<(), WatchError<ST>>

Park a new hanging get in the handler. If a hanging get is already parked, returns the new responder.

source

pub fn set_change_function( &mut self, change_function: Box<dyn Fn(&T, &T) -> bool + Send + Sync + 'static> )

Sets a new change function. The hanging get will only return when the change function evaluates to true when comparing the last value sent to the client and the current value. Takes effect immediately; if change function evaluates to true then the pending responder will be called.

source

pub fn set_value(&mut self, new_value: T)

Called to update the current value of the handler, sending changes using the watcher if needed.

Auto Trait Implementations§

§

impl<T, ST> Freeze for WatchHandler<T, ST>
where ST: Freeze, T: Freeze,

§

impl<T, ST> !RefUnwindSafe for WatchHandler<T, ST>

§

impl<T, ST> Send for WatchHandler<T, ST>
where ST: Send, T: Send,

§

impl<T, ST> Sync for WatchHandler<T, ST>
where ST: Sync, T: Sync,

§

impl<T, ST> Unpin for WatchHandler<T, ST>
where ST: Unpin, T: Unpin,

§

impl<T, ST> !UnwindSafe for WatchHandler<T, ST>

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, 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>,

§

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>,

§

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.