Struct calloop_wayland_source::WaylandSource
source · pub struct WaylandSource<D> { /* private fields */ }
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.
Implementations§
source§impl<D> WaylandSource<D>
impl<D> WaylandSource<D>
sourcepub fn new(connection: Connection, queue: EventQueue<D>) -> WaylandSource<D>
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
sourcepub fn queue(&mut self) -> &mut EventQueue<D>
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.
sourcepub fn connection(&self) -> &Connection
pub fn connection(&self) -> &Connection
Access the connection to the Wayland server
sourcepub fn insert(
self,
handle: LoopHandle<'_, D>
) -> Result<RegistrationToken, InsertError<Self>>where
D: 'static,
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.
Trait Implementations§
source§impl<D: Debug> Debug for WaylandSource<D>
impl<D: Debug> Debug for WaylandSource<D>
source§impl<D> EventSource for WaylandSource<D>
impl<D> EventSource for WaylandSource<D>
§type Metadata = EventQueue<D>
type Metadata = EventQueue<D>
The underlying event queue.
You should call EventQueue::dispatch_pending
inside your callback
using this queue.
§type Error = Error
type Error = Error
process_events()
(not the user callback!).source§const NEEDS_EXTRA_LIFECYCLE_EVENTS: bool = true
const NEEDS_EXTRA_LIFECYCLE_EVENTS: bool = true
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 notificationssource§fn process_events<F>(
&mut self,
_: Readiness,
_: Token,
callback: F
) -> Result<PostAction, Self::Error>
fn process_events<F>( &mut self, _: Readiness, _: Token, callback: F ) -> Result<PostAction, Self::Error>
source§fn register(
&mut self,
poll: &mut Poll,
token_factory: &mut TokenFactory
) -> Result<()>
fn register( &mut self, poll: &mut Poll, token_factory: &mut TokenFactory ) -> Result<()>
source§fn reregister(
&mut self,
poll: &mut Poll,
token_factory: &mut TokenFactory
) -> Result<()>
fn reregister( &mut self, poll: &mut Poll, token_factory: &mut TokenFactory ) -> Result<()>
source§fn unregister(&mut self, poll: &mut Poll) -> Result<()>
fn unregister(&mut self, poll: &mut Poll) -> Result<()>
source§fn before_sleep(&mut self) -> Result<Option<(Readiness, Token)>>
fn before_sleep(&mut self) -> Result<Option<(Readiness, Token)>>
poll
is about to begin Read moresource§fn before_handle_events(&mut self, events: EventIterator<'_>)
fn before_handle_events(&mut self, events: EventIterator<'_>)
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 moreAuto Trait Implementations§
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> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
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>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
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)
fn as_any(&self) -> &(dyn Any + 'static)
&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)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.