Skip to main content

U3vFrameStream

Struct U3vFrameStream 

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

Frames from a USB3 Vision camera, read on a thread of its own.

next_frame waits asynchronously, next_frame_blocking on the calling thread; neither needs the other. A stream from U3vStreamBuilder or Camera::open_stream clears the device’s StreamEnable when it is closed or dropped.

A transfer that fails is recovered from — the endpoint reset, the block in progress lost and counted — and the stream goes on; a camera that is unplugged ends it with U3vError::Disconnected as the source of the error, and marks the camera’s transport lost (U3vRegisterIo::is_lost).

ⓘ
let mut frames = camera.open_stream(U3vStreamOptions::default())?;
camera.acquisition_start()?;
while let Some(frame) = frames.next_frame().await? {
    println!("{}x{} frame {}", frame.width, frame.height, frame.block_id);
}

Implementations§

Source§

impl U3vFrameStream

Source

pub fn start(stream: U3vStream) -> Self

Read frames from stream, a stream already configured and enabled on the device. Nothing clears the device’s StreamEnable when it ends; U3vStreamBuilder starts streams that do.

Source

pub fn set_deliver_incomplete(&mut self, deliver: bool)

Also deliver frames that did not complete — a block given up before its trailer, or one whose trailer reports an error — with their FrameStatus saying how (default: off). Every incomplete frame is counted in StreamStats::frames_incomplete either way.

Source

pub fn set_time_sync(&mut self, time_sync: TimeSync)

Map device timestamps to host time with time_sync, fitted by Camera::time_calibrate.

Source

pub fn stats(&self) -> StreamStats

Snapshot the stream’s counters.

Source

pub fn stats_handle(&self) -> StreamStatsAccumulator

A clone of the counters’ handle, readable from any thread.

Source

pub async fn next_frame(&mut self) -> Result<Option<Frame>, GenicamError>

Receive the next frame. Ok(None) means the stream has ended. Cancel-safe.

Source

pub fn next_frame_blocking( &mut self, timeout: Duration, ) -> Result<Option<Frame>, GenicamError>

Wait up to timeout for the next frame on the calling thread: Ok(None) when the stream has ended, GenicamError::Timeout when nothing arrived.

Source

pub fn stop(&self)

Tell the reader to stop. It stops within a read poll; this does not wait for it, close does.

Source

pub fn close(self)

Stop the reader, wait for it, and clear the device’s StreamEnable: the endpoint and the device are free once this returns.

Source

pub async fn shutdown(self)

close, for async callers: the wait runs on the runtime’s blocking pool.

Trait Implementations§

Source§

impl Drop for U3vFrameStream

Source§

fn drop(&mut self)

A stream dropped without close still stops its reader and the device’s stream. If the device is busy, a thread of its own waits for it: the dropping thread must not block on a lock it may hold, and giving up left StreamEnable set (Codex review of #184).

Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. 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
§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more