pub struct WaylandSource {
    queue: EventQueue,
    fd: Generic<RawFd>,
    read_guard: Option<ReadEventsGuard>,
}
Expand description

An adapter to insert a Wayland EventQueue into a calloop event loop

This is a struct that implements calloop::EventSource. It generates an event whenever events need to be dispatched. At this point your calloop callback will be given access to the EventQueue and you should call .dispatch_pending() and forward its return value, allowing you to handle orphan events as you prefer.

If you don’t use orphan events, the quick_insert method will directly insert the source into a provided LoopHandle with an adapter which will panic whenever an oprhan event is encountered.

Fields§

§queue: EventQueue§fd: Generic<RawFd>§read_guard: Option<ReadEventsGuard>

Implementations§

source§

impl WaylandSource

source

pub fn new(queue: EventQueue) -> WaylandSource

Wrap an EventQueue as a WaylandSource.

source

pub fn quick_insert<Data: 'static>( self, handle: LoopHandle<'_, Data> ) -> Result<RegistrationToken, InsertError<WaylandSource>>

Insert this source into given event loop with an adapter that panics on orphan events

The adapter will pass the event loop’s global shared data as dispatch_data too all callbacks.

source

pub fn queue(&mut self) -> &mut EventQueue

Access the underlying event queue

This method can be used if you need to access the underlying EventQueue while this WaylandSource is currently inserted in an event loop.

Note that you should be careful when interacting with it if you invoke methods that interact with the wayland socket (such as dispatch() or prepare_read()). These may interefere with the proper waking up of this event source in the event loop.

Trait Implementations§

source§

impl Debug for WaylandSource

source§

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

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

impl EventSource for WaylandSource

§

type Event = ()

The type of events generated by your source.
§

type Error = Error

The error type returned from process_events() (not the user callback!).
§

type Metadata = EventQueue

Some metadata of your event source Read more
§

type Ret = Result<u32, Error>

The return type of the user callback Read more
source§

fn process_events<F>( &mut self, readiness: Readiness, token: Token, callback: F ) -> Result<PostAction>where F: FnMut((), &mut EventQueue) -> Result<u32>,

Process any relevant events Read more
source§

fn register( &mut self, poll: &mut Poll, token_factory: &mut TokenFactory ) -> Result<()>

Register yourself to this poll instance Read more
source§

fn reregister( &mut self, poll: &mut Poll, token_factory: &mut TokenFactory ) -> Result<()>

Re-register your file descriptors Read more
source§

fn unregister(&mut self, poll: &mut Poll) -> Result<()>

Unregister your file descriptors Read more
source§

fn pre_run<F>(&mut self, callback: F) -> Result<()>where F: FnMut((), &mut EventQueue) -> Result<u32>,

Notification that a polling session is going to start Read more
source§

fn post_run<F>(&mut self, _: F) -> Result<()>where F: FnMut((), &mut EventQueue) -> Result<u32>,

Notification that the current polling session ended Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere 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 Twhere 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.