Proxy

Struct Proxy 

Source
pub struct Proxy<T: HasProxy + Refcounted> { /* private fields */ }
Expand description

Proxies are a central concept to how clients interact with a PipeWire server. The server has a list of objects (either instantiated locally, or by other clients). A number of these objects are exported to other clients to enumerate, interact with (call methods on) and be notified when they change (via events).

Clients discover exported objects using a Registry (itself also a proxy), which can be created using Core::registry(). The RegistryEvents::global event is triggered for each existing exported object (and subsequenty when new objects are created).

If an object is of interest, clients can “bind” to that object using Registry::bind(). This provides an object on which methods may be called, and event notifications may be received.

The object itself will be a specific type (such as Client, but will also have an associated Proxy<T> type (in this example, Proxy<Client>). The specific type provides methods and events that are specific to the object itself. In addition, the Proxy<T> type provides more general proxy-related methods and events.

Specific types implement the HasProxy trait, which allows maintaining a generic collection of these objects, while having the ability to downcast to the specific type. The HasProxy::proxy() method can be used to get the corresponding Proxy object.

Note that there are two IDs associated with a proxy. One is a “local” ID, which represents the client’s view of the object. The other is a “global” ID, which is the server’s view of the object. Due to the asynchronous nature of the protocol, it is possible that the client has a view of server objects that is not current. Global IDs might be reused, and this mechanism allows the server to keep track of what each client’s view of the server state is and avoid calling methods on objects that have gone away.

Implementations§

Source§

impl<T: HasProxy + Refcounted> Proxy<T>

Source

pub fn id(&self) -> Id

The “local” ID for this object.

Source

pub fn object(&self) -> Option<T>

Retrieves the specific object corresponding to this Proxy. Because the proxy holds a weak reference to the object, the returned value is an Option.

Source

pub fn bound_id(&self) -> Option<Id>

The “global” ID for this object.

Source

pub fn add_listener(&self, events: ProxyEvents) -> HookId

Register a listener for proxy events.

Source

pub fn remove_listener(&self, hook_id: HookId)

Remove a set of event listeners.

Trait Implementations§

Source§

impl<T: Clone + HasProxy + Refcounted> Clone for Proxy<T>

Source§

fn clone(&self) -> Proxy<T>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<T: HasProxy + Refcounted> Refcounted for Proxy<T>

Source§

type WeakRef = WeakProxy<T>

The type of a weak reference to the object
Source§

fn upgrade(this: &Self::WeakRef) -> Option<Self>

Try to convert a weak reference to a strong reference. If the underlying object isstill alive, returns a Some continaing the value. If the underlying object’s strong reference count dropped to zero, and was thus freed, this returns None.
Source§

fn downgrade(&self) -> Self::WeakRef

Create a weak reference to the object. This reference does not impact the object’s lifecycle, and merely allows us the option to try to retrieve the object using Self::upgrade().
Source§

impl<T: HasProxy + Refcounted> Send for Proxy<T>

Source§

impl<T: HasProxy + Refcounted> Sync for Proxy<T>

Auto Trait Implementations§

§

impl<T> Freeze for Proxy<T>

§

impl<T> RefUnwindSafe for Proxy<T>

§

impl<T> Unpin for Proxy<T>

§

impl<T> UnwindSafe for Proxy<T>

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

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

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.