Struct pipewire::LoopInner

source ·
pub struct LoopInner { /* private fields */ }

Implementations§

source§

impl LoopInner

source

pub unsafe fn from_raw(ptr: NonNull<pw_loop>) -> Self

Create a new loop from a raw pw_loop, taking ownership of it.

Safety

The provided pointer must point to a valid, well aligned pw_loop.

The raw loop should not be manually destroyed or moved, as the new LoopInner takes ownership of it.

source

pub fn new() -> Result<Self, Error>

Create a new LoopInner.

Methods from Deref<Target = LoopRef>§

source

pub fn as_raw(&self) -> &pw_loop

source

pub fn as_ptr(&self) -> *mut pw_loop

source

pub fn fd(&self) -> BorrowedFd<'_>

Get the file descriptor backing this loop.

source

pub unsafe fn enter(&self)

Enter a loop

Start an iteration of the loop. This function should be called before calling iterate and is typically used to capture the thread that this loop will run in.

Safety

Each call of enter must be paired with a call of leave.

source

pub unsafe fn leave(&self)

Leave a loop

Ends the iteration of a loop. This should be called after calling iterate.

Safety

Each call of leave must be paired with a call of enter.

source

pub fn iterate(&self, timeout: Duration) -> i32

Perform one iteration of the loop.

An optional timeout can be provided. 0 for no timeout, -1 for infinite timeout.

This function will block up to the provided timeout and then dispatch the fds with activity. The number of dispatched fds is returned.

This will automatically call Self::enter() on the loop before iterating, and Self::leave() afterwards.

Panics

This function will panic if the provided timeout as milliseconds does not fit inside a c_int integer.

source

pub unsafe fn iterate_unguarded(&self, timeout: Duration) -> i32

A variant of iterate() that does not call Self::enter() and Self::leave() on the loop.

Safety

Before calling this, Self::enter() must be called, and Self::leave() must be called afterwards.

source

pub fn add_io<I, F>( &self, io: I, event_mask: IoFlags, callback: F ) -> IoSource<'_, I>where I: AsRawFd, F: Fn(&mut I) + 'static, Self: Sized,

Register some type of IO object with a callback that is called when reading/writing on the IO object is available.

The specified event_mask determines whether to trigger when either input, output, or any of the two is avaiable.

The returned IoSource needs to take ownership of the IO object, but will provide a reference to the callback when called.

source

pub fn add_idle<F>(&self, enabled: bool, callback: F) -> IdleSource<'_>where F: Fn() + 'static,

Register a callback to be called whenever the loop is idle.

This can be enabled and disabled as needed with the enabled parameter, and also with the enable method on the returned source.

source

pub fn add_signal_local<F>( &self, signal: Signal, callback: F ) -> SignalSource<'_>where F: Fn() + 'static, Self: Sized,

Register a signal with a callback that is called when the signal is sent.

For example, this can be used to quit the loop when the process receives the SIGTERM signal.

source

pub fn add_event<F>(&self, callback: F) -> EventSource<'_>where F: Fn() + 'static, Self: Sized,

Register a new event with a callback that is called when the event happens.

The returned EventSource can be used to trigger the event.

source

pub fn add_timer<F>(&self, callback: F) -> TimerSource<'_>where F: Fn(u64) + 'static, Self: Sized,

Register a timer with the loop with a callback that is called after the timer expired.

The timer will start out inactive, and the returned TimerSource can be used to arm the timer, or disarm it again.

The callback will be provided with the number of timer expirations since the callback was last called.

Trait Implementations§

source§

impl AsRef<LoopRef> for LoopInner

source§

fn as_ref(&self) -> &LoopRef

Converts this type into a shared reference of the (usually inferred) input type.
source§

impl Debug for LoopInner

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for LoopInner

§

type Target = LoopRef

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl Drop for LoopInner

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for Twhere T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for Twhere T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.