Skip to main content

FakeCamera

Struct FakeCamera 

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

Handle to a running fake GigE Vision camera.

The camera runs as background tokio tasks. Call stop or drop the handle to shut down the camera.

Implementations§

Source§

impl FakeCamera

Source

pub fn builder() -> FakeCameraBuilder

Create a new builder.

Source

pub async fn start() -> Result<Self, Error>

Start a fake camera with default settings on 127.0.0.1:3956.

Source

pub fn local_addr(&self) -> SocketAddr

The local address the GVCP socket is bound to.

Source

pub fn port(&self) -> u16

The port the GVCP socket is listening on.

Source

pub fn commands(&self) -> &CommandCounters

Which register-access commands this camera has received, and where.

For tests that must assert how a value reached the device: READREG and READMEM return identical bytes, so a test that checks only the value cannot tell them apart.

Source

pub fn blocks_sent(&self) -> u64

GVSP blocks this camera has produced, including any its packet script then dropped whole.

The left-hand side of a receiver’s accounting identity: every block is complete, incomplete, missed or dropped to backpressure on the host.

Source

pub fn message_channel(&self) -> MessageChannelStats

What this camera’s message channel did: messages sent, how often, acknowledged or abandoned, and events lost to a full queue (events module: one message outstanding, sent again every GevMCTT until acknowledged, as an Allied Vision Manta G-125B does).

Source

pub fn resends(&self) -> ResendStats

What this camera did with PACKETRESEND_CMDs: requests received, packets sent again, packets it no longer held.

Source

pub fn spoofed_packets(&self) -> u64

Datagrams sent from the spoof_source address.

Source

pub async fn controller(&self) -> Option<SocketAddr>

The application holding control privilege — the address and port its commands come from — or None.

Source

pub async fn revoke_control(&self)

Give control privilege up on the device side, as a device does when the controller’s heartbeat expires: CCP reads 0 from then on.

Source

pub fn unplug(&self)

Take the camera’s link down, as a pulled cable does: from now on every datagram to it is lost unanswered, and every one it sends — stream, events — is lost on the way. The camera itself runs on: it keeps acquiring, and its heartbeat timer keeps counting. plug_in brings the link back.

Source

pub fn plug_in(&self)

Bring the link unplug took down back up.

Source

pub fn heartbeat_expiries(&self) -> u64

How often the heartbeat rule has revoked control privilege.

Source

pub fn actions(&self) -> u64

Action commands this camera acted on: its device key, group key and a group mask that shares a bit with its own (FAKE_DEVICE_KEY, FAKE_GROUP_KEY, FAKE_GROUP_MASK). One addressed elsewhere, or malformed, is not counted.

Source

pub fn discovery_requests(&self) -> Vec<DiscoveryRequest>

Every DISCOVERY_CMD this camera received, in arrival order.

Source

pub async fn peek(&self, addr: u64, len: usize) -> Vec<u8> ⓘ

Read len bytes of device state directly, bypassing GVCP.

Not subject to access modes and not counted, so a test can check what a write actually stored without trusting the client’s own read-back.

Source

pub async fn event_notification_on(&self, event_id: u16) -> bool

Whether EventNotification is On for event_id, as the device keeps it per event, whatever EventSelector currently selects. Read past the protocol, like FakeCamera::peek.

Source

pub async fn software_triggers(&self) -> u64

How many times TriggerSoftware was executed, counted by the device.

Source

pub async fn saved_exposure(&self, set: u32) -> Option<f64>

The exposure saved in user set set by UserSetSave, or None if nothing has been saved there. Read past the protocol, like FakeCamera::peek.

Source

pub async fn stop(self)

Stop the fake camera and wait for its background tasks to exit.

The GVCP server cancels and drains its delayed acknowledgements, then the other tasks are aborted and joined. No delayed task retains the listening socket when this returns: a later fixture must not compete with an obsolete socket for datagrams on the same port.

Trait Implementations§

Source§

impl Drop for FakeCamera

Source§

fn drop(&mut self)

Best-effort cleanup when the handle is dropped without calling stop. Does not wait for tasks to exit — use stop().await for that.

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