pub struct CoreBox<'c> { /* private fields */ }Expand description
Smart pointer providing unique ownership of a PipeWire core.
For shared ownership, see CoreRc.
For an explanation of these, see Smart pointers to PipeWire objects.
Implementations§
Source§impl<'c> CoreBox<'c>
impl<'c> CoreBox<'c>
Sourcepub unsafe fn from_raw(raw: NonNull<pw_core>) -> CoreBox<'c>
pub unsafe fn from_raw(raw: NonNull<pw_core>) -> CoreBox<'c>
Create a CoreBox by taking ownership of a raw pw_core.
§Safety
The provided pointer must point to a valid, well aligned pw_core.
The raw core must not be manually destroyed or moved, as the new CoreBox takes
ownership of it.
The lifetime of the returned box is unbounded. The caller is responsible to make sure that the context used with this core outlives the core.
pub fn into_raw(self) -> NonNull<pw_core>
Methods from Deref<Target = Core>§
pub fn as_raw(&self) -> &pw_core
pub fn as_raw_ptr(&self) -> *mut pw_core
pub fn add_listener_local(&self) -> ListenerLocalBuilder<'_>
pub fn get_registry(&self) -> Result<RegistryBox<'_>, Error>
Sourcepub fn sync(&self, seq: i32) -> Result<AsyncSeq, Error>
pub fn sync(&self, seq: i32) -> Result<AsyncSeq, Error>
Do server roundtrip.
Ask the server to emit the done event with seq.
Since methods are handled in-order and events are delivered in-order, this can be used as a barrier to ensure all previous methods and the resulting events have been handled.
Sourcepub fn create_object<P: ProxyT>(
&self,
factory_name: &str,
properties: &impl AsRef<DictRef>,
) -> Result<P, Error>
pub fn create_object<P: ProxyT>( &self, factory_name: &str, properties: &impl AsRef<DictRef>, ) -> Result<P, Error>
Create a new object on the PipeWire server from a factory.
You will need specify what type you are expecting to be constructed by either using type inference or the turbofish syntax.
§Parameters
factory_namethe name of the factory to usepropertiesextra properties that the new object will have
§Panics
If factory_name contains a null byte.
§Returns
One of:
Ok(P)on success, wherePis the newly created objectErr(Error::CreationFailed)if the object could not be createdErr(Error::WrongProxyType)if the created type does not match the typePthat the user is trying to create
§Examples
Creating a new link:
use pipewire as pw;
pw::init();
let mainloop = pw::MainLoop::new().expect("Failed to create Pipewire Mainloop");
let context = pw::Context::new(&mainloop).expect("Failed to create Pipewire Context");
let core = context
.connect(None)
.expect("Failed to connect to Pipewire Core");
// This call uses turbofish syntax to specify that we want a link.
let link = core.create_object::<pw::link::Link>(
// The actual name for a link factory might be different for your system,
// you should probably obtain a factory from the registry.
"link-factory",
&pw::properties! {
"link.output.port" => "1",
"link.input.port" => "2",
"link.output.node" => "3",
"link.input.node" => "4"
},
)
.expect("Failed to create object");See pipewire/examples/create-delete-remote-objects.rs in the crates repository for a more detailed example.