Skip to main content

StreamBuilder

Struct StreamBuilder 

Source
pub struct StreamBuilder<'a> { /* private fields */ }
Expand description

Builder for configuring a GVSP stream.

Implementations§

Source§

impl<'a> StreamBuilder<'a>

Source

pub fn new(device: &'a mut GigeDevice) -> Self

Create a new builder bound to an opened GigeDevice.

Default packet-size policy is preserve: the camera’s current GevSCPSPacketSize is used as-is. Call StreamBuilder::auto_packet_size to set from the NIC MTU and path-probe, or StreamBuilder::packet_size for an explicit ceiling (ADR-0021).

Source

pub fn probe(self, enable: bool) -> Self

Whether to path-probe with a GVSP test packet before streaming (default: on, under every packet-size policy).

It applies under the default preserve policy too, which is not a contradiction: the probe never raises a size, so it cannot override the value an operator set. It can only decline to stream at a size the path demonstrably drops — something no register read can discover, because both endpoints accept it. Turning it off is what makes preserve literal.

Turning it off restores the pre-0.4.2 behaviour: whatever GevSCPSPacketSize holds is assumed to reach the host. That is wrong on any path narrower than both endpoints (#112), so the only good reason to disable it is a device that misbehaves when asked for a test packet — in which case please open an issue, because the probe is written to tolerate a device that simply ignores it.

Source

pub fn iface(self, iface: Iface) -> Self

Select the interface used for receiving GVSP packets.

Source

pub fn dest(self, dest: StreamDest) -> Self

Configure the stream destination.

Source

pub fn target_mtu(self, mtu: u32) -> Self

Cap the MTU used when computing the GVSP packet size in StreamBuilder::auto_packet_size mode.

The interface’s own MTU is still read; this only lowers the request.

Source

pub fn auto_packet_size(self) -> Self

Set GevSCPSPacketSize from the host NIC MTU, then path-probe (SR-13).

This is the explicit opt-in that replaces the old always-write-MTU default (ADR-0021). It is not the pre-0.4 --auto false ⇒ 1500 behaviour.

Source

pub fn packet_size(self, size: u32) -> Self

Write this GVSP packet size (a ceiling for the path probe).

Source

pub fn packet_delay(self, delay: Duration) -> Self

Have the camera wait delay between stream packets: GevSCPD, written in timestamp ticks at the frequency the camera reports (0x093C/0x0940), rounded to the nearest tick.

Without it GevSCPD is left as it is. A camera that reports no tick frequency cannot be given a delay in time, and the build fails rather than guess a unit.

Source

pub fn resend(self, policy: ResendPolicy) -> Self

Whether to ask the camera for lost packets (default ResendPolicy::Auto).

Source

pub fn destination_port(self, port: u16) -> Self

Receive on this UDP port, for a firewall that admits only it.

By default the operating system picks a free port; either way the port is written to the camera’s GevSCPHostPort. The port is the stream’s alone: it is bound without SO_REUSEPORT, so a second stream asking for the same one fails to open.

Source

pub fn multicast(self, group: Option<Ipv4Addr>) -> Self

Configure multicast reception when the device is set to multicast mode.

Source

pub fn rcvbuf_bytes(self, size: usize) -> Self

Custom receive buffer size for the UDP socket.

Source

pub fn channel(self, channel: u32) -> Self

Select the GigE Vision stream channel to configure (defaults to 0).

The build fails for a channel at or beyond the camera’s GevNumberOfStreamChannels (0x0904), before anything is written.

Source

pub async fn build(self) -> Result<Stream, GenicamError>

Finalise the builder and return a configured Stream.

In order: check the channel exists and that a requested packet delay can be converted, bind the socket (port 0 unless one was asked for), point the stream channel at it, negotiate the packet size, write GevSCPD if asked, and read whether the camera supports resend.

Trait Implementations§

Source§

impl<'a> From<&'a mut GigeDevice> for StreamBuilder<'a>

Source§

fn from(device: &'a mut GigeDevice) -> Self

Converts to this type from the input type.

Auto Trait Implementations§

§

impl<'a> !UnwindSafe for StreamBuilder<'a>

§

impl<'a> Freeze for StreamBuilder<'a>

§

impl<'a> RefUnwindSafe for StreamBuilder<'a>

§

impl<'a> Send for StreamBuilder<'a>

§

impl<'a> Sync for StreamBuilder<'a>

§

impl<'a> Unpin for StreamBuilder<'a>

§

impl<'a> UnsafeUnpin for StreamBuilder<'a>

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