Skip to main content

ReceiverOptionsBuilder

Struct ReceiverOptionsBuilder 

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

Builder for configuring a ReceiverOptions with ergonomic method chaining

Implementations§

Source§

impl ReceiverOptionsBuilder

Source

pub fn new(source: Source) -> Self

Create a new builder with the specified source

Source

pub fn snapshot_preset(source: Source) -> Self

Preset for capturing snapshots (low resolution, RGBA, lowest bandwidth).

This preset is optimized for:

  • Image export and snapshot capture
  • AI/ML processing pipelines
  • Thumbnail generation
  • Low bandwidth environments

Configuration:

  • Color format: RGBX_RGBA (compatible with image encoding)
  • Bandwidth: Lowest (reduces resolution and bitrate)
  • Video fields: Disabled (progressive frames only)
§Example
let options = ReceiverOptionsBuilder::snapshot_preset(sources[0].clone())
    .name("Snapshot Receiver")
    .build();
let receiver = Receiver::new(&ndi, &options)?;

// Capture and encode in one line (requires image-encoding feature)
#[cfg(feature = "image-encoding")]
{
    let frame = receiver.video().capture(Duration::from_secs(5))?;
    let png_bytes = frame.encode_png()?;
    std::fs::write("snapshot.png", &png_bytes)?;
}
Source

pub fn high_quality_preset(source: Source) -> Self

Preset for high-quality video processing (full resolution, highest bandwidth).

This preset is optimized for:

  • Professional video processing workflows
  • Recording and archival
  • Real-time video analysis requiring full quality
  • Broadcasting and production

Configuration:

  • Color format: RGBX_RGBA (uncompressed, compatible with most tools)
  • Bandwidth: Highest (full resolution and bitrate)
  • Video fields: Enabled (supports interlaced sources)
§Example
let options = ReceiverOptionsBuilder::high_quality_preset(sources[0].clone())
    .name("High Quality Receiver")
    .build();
let receiver = Receiver::new(&ndi, &options)?;

// Capture full quality frames
let frame = receiver.video().capture(Duration::from_secs(5))?;
println!("Captured {width}x{height} frame", width = frame.width(), height = frame.height());
Source

pub fn monitoring_preset(source: Source) -> Self

Preset for metadata and tally monitoring only (no video/audio).

This preset is optimized for:

  • Tally light monitoring
  • Connection status tracking
  • PTZ control applications
  • Minimal bandwidth overhead

Configuration:

  • Bandwidth: MetadataOnly (no video or audio data)
  • Color format: Default (not used for metadata-only)
  • Video fields: Disabled (not applicable)
§Example
let options = ReceiverOptionsBuilder::monitoring_preset(sources[0].clone())
    .name("Tally Monitor")
    .build();
let receiver = Receiver::new(&ndi, &options)?;

// Poll for status changes
if let Some(status) = receiver.poll_status_change(Duration::from_millis(1000))? {
    if let Some(tally) = status.tally {
        println!("Tally: program={program}, preview={preview}",
                 program = tally.on_program, preview = tally.on_preview);
    }
    if let Some(connections) = status.connections {
        println!("Active connections: {connections}");
    }
}
Source

pub fn color(self, fmt: ReceiverColorFormat) -> Self

Set the color format for received video

Source

pub fn bandwidth(self, bw: ReceiverBandwidth) -> Self

Set the bandwidth mode for the receiver

Source

pub fn allow_video_fields(self, allow: bool) -> Self

Configure whether to allow video fields

Source

pub fn name<S: Into<String>>(self, name: S) -> Self

Set the name for this receiver

Source

pub fn build(self) -> ReceiverOptions

Build the receiver options

This method is infallible and simply applies defaults for any unset options. To create a Receiver, pass the resulting ReceiverOptions to Receiver::new().

§Example
let options = ReceiverOptions::builder(source).build();
let receiver = Receiver::new(&ndi, &options)?;

Trait Implementations§

Source§

impl Clone for ReceiverOptionsBuilder

Source§

fn clone(&self) -> ReceiverOptionsBuilder

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 Debug for ReceiverOptionsBuilder

Source§

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

Formats the value using the given formatter. 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> 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.