Skip to main content

EventSocket

Struct EventSocket 

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

A GVCP message channel: the socket a device sends its events to.

Binding starts a receive thread. It acknowledges each message as it arrives, whether or not the application is reading, and queues its events for recv, up to EVENT_QUEUE_CAPACITY; past that the oldest is dropped, counted in EventStats::dropped and logged. A device whose acknowledgement does not come resends the message every GevMCTT and holds back the events behind it: an Allied Vision Manta G-125B (GevMCTT 100 ms) sent one ExposureEnd twelve times to an application that read a second late when the acknowledgement waited for the read, and, left unread for ten seconds, kept 44 events and sent EventOverflow for the rest.

A retransmission repeats the request id and the bytes of the message before it; it is acknowledged again and its events are not queued twice. Distinct events under one request id are each queued. Dropping the socket stops the thread within one tick.

Implementations§

Source§

impl EventSocket

Source

pub async fn bind(local_ip: IpAddr, port: u16) -> Result<Self>

Bind a GVCP message socket on the provided local address and start its receive thread.

Source

pub async fn recv(&self) -> Result<EventPacket>

The next event, waiting until one arrives. Events come in the order the device sent them; a datagram carrying several is queued whole.

Cancel-safe: an event is taken only by the poll that returns it. Concurrent callers are symmetric consumers of one queue. An error once the receive thread has failed, after the events it queued.

Source

pub fn stats(&self) -> EventStats

What the receive thread has counted so far.

Source

pub fn local_addr(&self) -> Result<SocketAddr>

Return the local address bound to the socket.

Trait Implementations§

Source§

impl Drop for EventSocket

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
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
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.

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