Struct calloop_wayland_source::WaylandSource

source ·
pub struct WaylandSource<D> {
    pub(crate) queue: EventQueue<D>,
    pub(crate) connection_source: Generic<Connection>,
    pub(crate) read_guard: Option<ReadEventsGuard>,
    pub(crate) fake_token: Option<Token>,
    pub(crate) stored_error: Result<(), Error>,
}
Expand description

An adapter to insert an EventQueue into a calloop EventLoop.

This type implements EventSource which generates an event whenever events on the event queue need to be dispatched. The event queue available in the callback calloop registers may be used to dispatch pending events using EventQueue::dispatch_pending.

WaylandSource::insert can be used to insert this source into an event loop and automatically dispatch pending events on the event queue.

Fields§

§queue: EventQueue<D>§connection_source: Generic<Connection>§read_guard: Option<ReadEventsGuard>§fake_token: Option<Token>

Calloop’s before_will_sleep method allows skipping the sleeping by returning a Token. We cannot produce this on the fly, so store it here instead

§stored_error: Result<(), Error>

Implementations§

source§

impl<D> WaylandSource<D>

source

pub fn new(connection: Connection, queue: EventQueue<D>) -> WaylandSource<D>

Wrap an EventQueue as a WaylandSource.

queue must be from the connection Connection. This is not a safety invariant, but not following this may cause freezes or hangs

source

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

Access the underlying event queue

Note that you should not replace this queue with a queue from a different Connection, as that may cause freezes or other hangs.

source

pub fn connection(&self) -> &Connection

Access the connection to the Wayland server

source

pub fn insert( self, handle: LoopHandle<'_, D>, ) -> Result<RegistrationToken, InsertError<Self>>
where D: 'static,

Insert this source into the given event loop.

This adapter will pass the event loop’s shared data as the D type for the event loop.

source§

impl<D> WaylandSource<D>

source

pub(crate) fn loop_callback_pending<F>( queue: &mut EventQueue<D>, callback: &mut F, ) -> Result<()>
where F: FnMut((), &mut EventQueue<D>) -> Result<usize, DispatchError>,

Loop over the callback until all pending messages have been dispatched.

Trait Implementations§

source§

impl<D: Debug> Debug for WaylandSource<D>

source§

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

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

impl<D> EventSource for WaylandSource<D>

§

type Metadata = EventQueue<D>

The underlying event queue.

You should call EventQueue::dispatch_pending inside your callback using this queue.

§

type Error = Error

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

type Event = ()

The type of events generated by your source.
§

type Ret = Result<usize, DispatchError>

The return type of the user callback Read more
source§

const NEEDS_EXTRA_LIFECYCLE_EVENTS: bool = true

Whether this source needs to be sent the EventSource::before_sleep and EventSource::before_handle_events notifications. These are opt-in because they require more expensive checks, and almost all sources will not need these notifications
source§

fn process_events<F>( &mut self, _: Readiness, _: Token, callback: F, ) -> Result<PostAction, Self::Error>
where F: FnMut(Self::Event, &mut Self::Metadata) -> Self::Ret,

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 before_sleep(&mut self) -> Result<Option<(Readiness, Token)>>

Notification that a single poll is about to begin Read more
source§

fn before_handle_events(&mut self, events: EventIterator<'_>)

Notification that polling is complete, and EventSource::process_events will be called with the given events for this source. The iterator may be empty, which indicates that no events were generated for this source Read more

Auto Trait Implementations§

§

impl<D> Freeze for WaylandSource<D>

§

impl<D> !RefUnwindSafe for WaylandSource<D>

§

impl<D> !Send for WaylandSource<D>

§

impl<D> !Sync for WaylandSource<D>

§

impl<D> Unpin for WaylandSource<D>

§

impl<D> !UnwindSafe for WaylandSource<D>

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> Downcast for T
where T: Any,

source§

fn into_any(self: Box<T>) -> Box<dyn Any>

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.
source§

fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait.
source§

fn as_any(&self) -> &(dyn Any + 'static)

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s.
source§

fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s.
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, 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.
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