PropBuilder

Struct PropBuilder 

Source
pub struct PropBuilder<'a, T: 'static, A: 'static> { /* private fields */ }
Expand description

Struct used to describe a property when building an interface.

Implementations§

Source§

impl<T: Send, A: Send + RefArg + Arg + Append> PropBuilder<'_, T, A>

Source

pub fn get<CB>(self, cb: CB) -> Self
where CB: FnMut(&mut PropContext, &mut T) -> Result<A, MethodErr> + Send + 'static,

Source

pub fn get_with_cr<CB>(self, cb: CB) -> Self
where CB: FnMut(&mut PropContext, &mut Crossroads) -> Result<A, MethodErr> + Send + 'static,

Source

pub fn get_with_cr_async<R, CB>(self, cb: CB) -> Self
where CB: FnMut(PropContext, &mut Crossroads) -> R + Send + 'static, R: Future<Output = PhantomData<A>> + Send + 'static,

Source

pub fn get_async<R, CB>(self, cb: CB) -> Self
where CB: FnMut(PropContext, &mut T) -> R + Send + 'static, R: Future<Output = PhantomData<A>> + Send + 'static,

Source

pub fn changed_msg_fn( self, ) -> Box<dyn Fn(&Path<'_>, &dyn RefArg) -> Option<Message> + Send + Sync + 'static>

Returns a function which, when called, creates a PropertiesChanged message.

Call the resulting function with the path that the object belongs to, and a reference to the new value. If a PropertiesChanged message should be sent (this depends on the emits_changed function called), such a message will be returned.

§Panics

If emits_changed is set to “const”, the function will panic.

Source§

impl<T: Send, A: RefArg + Send + for<'x> Get<'x> + Arg + Append> PropBuilder<'_, T, A>

Source

pub fn set<CB>(self, cb: CB) -> Self
where CB: FnMut(&mut PropContext, &mut T, A) -> Result<Option<A>, MethodErr> + Send + 'static,

Adds a set property handler to this property.

In case an EmitsChangedSignal should be emitted, the callback should return Ok(Some(v)) where v is the value to be emitted. If no EmitsChangedSignal should be emitted, return Ok(None).

Source

pub fn set_with_cr<CB>(self, cb: CB) -> Self
where CB: FnMut(&mut PropContext, &mut Crossroads, A) -> Result<Option<A>, MethodErr> + Send + 'static,

Adds a set property handler to this property, and allowing the entire tree to be changed.

In case an EmitsChangedSignal should be emitted, the callback should return Ok(Some(v)) where v is the value to be emitted. If no EmitsChangedSignal should be emitted, return Ok(None).

Source

pub fn set_custom<CB>(self, cb: CB) -> Self
where CB: FnMut(PropContext, &mut Crossroads, A) -> Option<PropContext> + Send + 'static,

Source

pub fn set_with_cr_async<CB, R>(self, cb: CB) -> Self
where CB: FnMut(PropContext, &mut Crossroads, A) -> R + Send + 'static, R: Future<Output = PhantomData<Option<A>>> + Send + 'static,

Source

pub fn set_async<CB, R>(self, cb: CB) -> Self
where CB: FnMut(PropContext, &mut T, A) -> R + Send + 'static, R: Future<Output = PhantomData<Option<A>>> + Send + 'static,

Source§

impl<T: Send, A> PropBuilder<'_, T, A>

Source

pub fn annotate<N: Into<String>, V: Into<String>>( self, name: N, value: V, ) -> Self

Source

pub fn deprecated(self) -> Self

Source

pub fn emits_changed_false(self) -> Self

Source

pub fn emits_changed_const(self) -> Self

This means that the property never changes. Attempts to change it or make an “PropertiesChanged” signal will result in a panic.

Source

pub fn emits_changed_invalidates(self) -> Self

Source

pub fn emits_changed_true(self) -> Self

Trait Implementations§

Source§

impl<'a, T: Debug + 'static, A: Debug + 'static> Debug for PropBuilder<'a, T, A>

Source§

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

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

impl<T, A> Drop for PropBuilder<'_, T, A>

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<'a, T, A> Freeze for PropBuilder<'a, T, A>

§

impl<'a, T, A> !RefUnwindSafe for PropBuilder<'a, T, A>

§

impl<'a, T, A> Send for PropBuilder<'a, T, A>
where T: Sync, A: Sync,

§

impl<'a, T, A> !Sync for PropBuilder<'a, T, A>

§

impl<'a, T, A> Unpin for PropBuilder<'a, T, A>

§

impl<'a, T, A> !UnwindSafe for PropBuilder<'a, T, A>

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.