Enum EventBody

Source
pub enum EventBody<'a> {
    Owned(EventBodyOwned),
    Borrowed(EventBodyBorrowed<'a>),
}
Expand description

Common event body that can be either owned or borrowed.

This is useful for APIs that can return either owned or borrowed event bodies.
Having this type allows to be generic over the event body type.

Variants§

Implementations§

Source§

impl<'a> EventBody<'_>

Source

pub fn as_owned(&self) -> Result<EventBodyOwned, AtspiError>

Non-consuming conversion to an owned event body.

Does cloning.

§Errors

The borrowed variant will error if the following conditions are met:

  1. the any_data field contains an [std::os::fd::OwnedFd] type, and
  2. the maximum number of open files for the process is exceeded.
Source

pub fn into_owned(self) -> Result<EventBodyOwned, AtspiError>

Consuming conversion to an owned event body.

Does cloning.

§Errors

The borrowed variant will error if the following conditions are met:

  1. the any_data field contains an [std::os::fd::OwnedFd] type, and
  2. the maximum number of open files for the process is exceeded.
Source

pub fn kind(&'a self) -> &'a str

The kind field as &str.

With both variants, this method returns a reference to the kind field.

Source

pub fn take_kind(&mut self) -> String

Take or convert the kind field as String.

With the owned variant, this method takes the kind field and replaces it with an empty string. With the borrowed variant, this method clones and allocates the kind field.

Source

pub fn detail1(&self) -> i32

Source

pub fn detail2(&self) -> i32

Source

pub fn any_data(&'a self) -> &'a Value<'a>

The any_data field as &Value. With both variants, this method returns a reference to the any_data field.

Source

pub fn take_any_data(&mut self) -> OwnedValue

Take or convert the any_data field as OwnedValue. With the owned variant, this method takes the any_data field and replaces it with a default value. As Value does not have a default value, we will replace with 0_u32, a nbon-allocating value.

With the borrowed variant, this method clones and allocates the any_data field.

§Panics

This method will panic if the any_data field contains an [std::os::fd::OwnedFd] type, and the maximum number of open files for the process is exceeded.

None of the types in crate::events use [std::os::fd::OwnedFd]. Events on the AT-SPI bus could, theoretically send a file descriptor, but nothing in the current specification describes that.

Trait Implementations§

Source§

impl<'a> Clone for EventBody<'a>

Source§

fn clone(&self) -> EventBody<'a>

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for EventBody<'a>

Source§

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

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

impl Default for EventBody<'_>

Source§

fn default() -> Self

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

impl<'de> Deserialize<'de> for EventBody<'de>

Source§

fn deserialize<D>(deserializer: D) -> Result<EventBody<'de>, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl From<EventBody<'_>> for EventBodyQtOwned

Source§

fn from(event: EventBody<'_>) -> Self

Converts to this type from the input type.
Source§

impl<'b> From<EventBodyBorrowed<'b>> for EventBody<'b>

Source§

fn from(borrowed: EventBodyBorrowed<'b>) -> Self

Converts to this type from the input type.
Source§

impl From<EventBodyOwned> for EventBody<'_>

Source§

fn from(owned: EventBodyOwned) -> Self

Converts to this type from the input type.
Source§

impl<'a> From<EventBodyQtBorrowed<'a>> for EventBody<'a>

Source§

fn from(qt_borrowed: EventBodyQtBorrowed<'a>) -> Self

Converts to this type from the input type.
Source§

impl From<EventBodyQtOwned> for EventBody<'_>

Source§

fn from(qt_owned: EventBodyQtOwned) -> Self

Converts to this type from the input type.
Source§

impl<'a> PartialEq for EventBody<'a>

Source§

fn eq(&self, other: &EventBody<'a>) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for EventBody<'_>

Source§

fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error>
where S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl Type for EventBody<'_>

Source§

const SIGNATURE: &'static Signature = EventBodyOwned::SIGNATURE

The signature for the implementing type, in parsed format. Read more
Source§

impl<'a> StructuralPartialEq for EventBody<'a>

Auto Trait Implementations§

§

impl<'a> Freeze for EventBody<'a>

§

impl<'a> RefUnwindSafe for EventBody<'a>

§

impl<'a> Send for EventBody<'a>

§

impl<'a> Sync for EventBody<'a>

§

impl<'a> Unpin for EventBody<'a>

§

impl<'a> UnwindSafe for EventBody<'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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<'de, T> DynamicDeserialize<'de> for T
where T: Type + Deserialize<'de>,

Source§

type Deserializer = PhantomData<T>

A DeserializeSeed implementation for this type.
Source§

fn deserializer_for_signature( signature: &Signature, ) -> Result<<T as DynamicDeserialize<'de>>::Deserializer, Error>

Get a deserializer compatible with this parsed signature.
Source§

impl<T> DynamicType for T
where T: Type + ?Sized,

Source§

fn signature(&self) -> Signature

The type signature for self. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> NoneValue for T
where T: Default,

Source§

type NoneType = T

Source§

fn null_value() -> T

The none-equivalent value.
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more