Skip to main content

AdaptedSource

Struct AdaptedSource 

Source
pub struct AdaptedSource<S: SceneSource> { /* private fields */ }
Expand description

Source wrapper that converts every emitted frame to a target pixel format.

Overrides the reported SourceFormat so the downstream sink’s init() sees the adapted canvas, not the scene’s native one. Cheap when the formats already match (the adapter short-circuits in adapt_frame_to).

Implementations§

Source§

impl<S: SceneSource> AdaptedSource<S>

Source

pub fn new(inner: S, target: PixelFormat) -> Self

Wrap inner, converting every pulled frame to target. Use this when a sink accepts a specific pixel format that differs from the scene’s canvas (e.g. RGB24 for a JPEG writer while the scene composes in YUV420P).

Source

pub fn inner(&self) -> &S

Access the wrapped source.

Source

pub fn inner_mut(&mut self) -> &mut S

Mutable access to the wrapped source — useful for the streaming-compositor pattern where the caller mutates scene state between pulls.

Trait Implementations§

Source§

impl<S: SceneSource> SceneSource for AdaptedSource<S>

Source§

fn format(&self) -> SourceFormat

Declared format. Constant across a session.
Source§

fn pull(&mut self) -> Result<Option<RenderedFrame>>

Produce the next rendered tick. Returns Ok(None) when the source is exhausted (finite scene reached its end). For indefinite sources, this never returns None.

Auto Trait Implementations§

§

impl<S> Freeze for AdaptedSource<S>
where S: Freeze,

§

impl<S> RefUnwindSafe for AdaptedSource<S>
where S: RefUnwindSafe,

§

impl<S> Send for AdaptedSource<S>
where S: Send,

§

impl<S> Sync for AdaptedSource<S>
where S: Sync,

§

impl<S> Unpin for AdaptedSource<S>
where S: Unpin,

§

impl<S> UnsafeUnpin for AdaptedSource<S>
where S: UnsafeUnpin,

§

impl<S> UnwindSafe for AdaptedSource<S>
where S: UnwindSafe,

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 = 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.