Skip to main content

Module smol

Module smol 

Source
Expand description

AsyncReceiver on the smol runtime: the generic asynchronous::AsyncReceiver with Smol, which run blocking work with smol::unblock.

§Example

use grafton_ndi::{Ndi, ReceiverOptions, asynchronous::smol::AsyncReceiver};

fn main() -> Result<(), grafton_ndi::Error> {
    ::smol::block_on(async {
        let ndi = Ndi::new()?;
        // ... obtain source ...

        let options = ReceiverOptions::snapshot_preset(source);
        let receiver = grafton_ndi::Receiver::new(&ndi, &options)?;
        let async_receiver = AsyncReceiver::new(receiver);

        // Capture without blocking the runtime
        match async_receiver.capture_video_with(std::time::Duration::from_millis(100), |frame| {
            (frame.width(), frame.height())
        }).await? {
            Some(size) => println!("Got dimensions: {size:?}"),
            None => println!("No frame available"),
        }

        Ok(())
    })
}

See mixed_media_async.rs for a complete smol example.

Type Aliases§

AsyncFinder
Source discovery on the smol runtime, owning a finder or source cache.
AsyncReceiver
An AsyncReceiver on the smol runtime.
AsyncSourceCache
Cached discovery on the smol runtime.
AsyncSourceWatch
An owned discovery cursor on the smol runtime.