Skip to main content

PortalHelper

Struct PortalHelper 

Source
pub struct PortalHelper { /* private fields */ }
Expand description

XDG Desktop Portal ScreenCast helper (Linux only).

Opens a ScreenCast portal session to obtain a PipeWire stream, whose FD and node ID can be handed to crate::controller::Controller::new_linux via crate::common::LinuxControllerConfig’s pw_socket_fd / pw_node_id.

On non-Linux platforms, PortalHelper::new returns MaaError::NullPointer because the underlying C API is unavailable there.

Implementations§

Source§

impl PortalHelper

Source

pub fn new() -> MaaResult<Self>

Create a new portal helper.

Source

pub fn open_stream(&self) -> MaaResult<()>

Open the ScreenCast portal stream (create DBus session, select sources, and start the stream).

Source

pub fn get_persist(&self) -> bool

Whether the portal session is persistent (i.e. can be restored later).

Source

pub fn set_persist(&self, enable: bool)

Set whether the portal session should persist for later restoration.

Source

pub fn get_pipewire_fd(&self) -> i32

The PipeWire socket FD, or -1 if the stream has not been opened yet.

Source

pub fn get_pipewire_node_id(&self) -> u32

The PipeWire node ID, or 0 if the stream has not been opened yet.

Source

pub fn get_restore_token(&self) -> String

The restore token used to restore a persistent session.

Returns an empty string when no token is available.

Source

pub fn set_restore_token(&self, token: &str) -> MaaResult<()>

Set the restore token to restore a previous portal session.

Trait Implementations§

Source§

impl Drop for PortalHelper

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

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> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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>,

Source§

type Error = !

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.