Struct MetadataListenerLocalBuilder

Source
pub struct MetadataListenerLocalBuilder<'meta> { /* private fields */ }
Expand description

A builder for registering metadata event callbacks.

Use Metadata::add_listener_local to create this and register callbacks that will be called when events of interest occur. After adding callbacks, use register to get back a MetadataListener.

§Examples

let metadata_listener = metadata.add_listener_local()
    .property(|subject, key, type_, value| {
        println!("Metadata property update: subject {subject}, key {key:?}, type {type_:?}, value {value:?}");
        0
    })
    .register();

Implementations§

Source§

impl<'meta> MetadataListenerLocalBuilder<'meta>

Source

pub fn property<F>(self, property: F) -> Self
where F: Fn(u32, Option<&str>, Option<&str>, Option<&str>) -> i32 + 'static,

Set the metadata property event callback of the listener.

§Callback parameters

subject, key, type, value.

None for key means removal of all properties. None for value means removal of property with key key.

§Examples
let metadata_listener = metadata.add_listener_local()
    .property(|subject, key, type_, value| {
        println!("Metadata property update: subject {subject}, key {key:?}, type {type_:?}, value {value:?}");
        0
    })
    .register();
Source

pub fn register(self) -> MetadataListener

Subscribe to events and register any provided callbacks.

Auto Trait Implementations§

§

impl<'meta> Freeze for MetadataListenerLocalBuilder<'meta>

§

impl<'meta> !RefUnwindSafe for MetadataListenerLocalBuilder<'meta>

§

impl<'meta> !Send for MetadataListenerLocalBuilder<'meta>

§

impl<'meta> !Sync for MetadataListenerLocalBuilder<'meta>

§

impl<'meta> Unpin for MetadataListenerLocalBuilder<'meta>

§

impl<'meta> !UnwindSafe for MetadataListenerLocalBuilder<'meta>

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

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.