Struct MprisHandle
pub struct MprisHandle { /* private fields */ }Expand description
The widget-side handle to the host’s media controls, started through the
current crate::host::MediaSessionFactory. When the host has none — the
default (non-mpris) build, non-Unix platforms, no session bus, headless
hosts — this is an inert stub: publish is a no-op and drain_commands
yields nothing, so the widget code path is identical everywhere.
Implementations§
§impl MprisHandle
impl MprisHandle
pub fn disabled() -> MprisHandle
pub fn disabled() -> MprisHandle
An inert handle (no D-Bus). Used by the default build, --shots, tests,
and as the graceful fallback when no session bus is reachable.
pub fn spawn(config: MprisConfig, initial: PlayerSnapshot) -> MprisHandle
pub fn spawn(config: MprisConfig, initial: PlayerSnapshot) -> MprisHandle
Register a player under config with the current host, publishing
initial as the starting state. Never panics: when the host has no
media controls it returns an inert Self::disabled.
pub fn drain_commands(&self) -> Vec<MprisCommand>
pub fn drain_commands(&self) -> Vec<MprisCommand>
Drain every pending external control command (non-blocking).
pub fn publish(&mut self, snap: PlayerSnapshot)
pub fn publish(&mut self, snap: PlayerSnapshot)
Publish the current player state to the host, which for MPRIS emits
PropertiesChanged for whatever changed. Cheap and deduped:
identical/insignificant updates are dropped so the bus isn’t spammed
each frame.
Trait Implementations§
§impl Default for MprisHandle
impl Default for MprisHandle
§fn default() -> MprisHandle
fn default() -> MprisHandle
Auto Trait Implementations§
impl Freeze for MprisHandle
impl !RefUnwindSafe for MprisHandle
impl Send for MprisHandle
impl !Sync for MprisHandle
impl Unpin for MprisHandle
impl UnsafeUnpin for MprisHandle
impl !UnwindSafe for MprisHandle
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
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more