Skip to main content

FakeVisionEngine

Struct FakeVisionEngine 

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

In-process stand-in for the vision engine + plugin host bridge.

Owns a synthetic frame ring and a queue of pending frames. A test registers a FrameCallback with on_frame, enqueues synthetic frames, then calls deliver_all (or deliver_one) to drive them through the resolver into the callback. Detections the plugin publishes are captured via the sink detection_sink returns.

Implementations§

Source§

impl FakeVisionEngine

Source

pub fn new( camera_id: &str, width: u32, height: u32, format: FrameFormat, ) -> Self

A fake engine for one camera at a fixed frame size and format. The ring is sized to hold full width x height frames.

Source

pub fn with_slot_count( camera_id: &str, width: u32, height: u32, format: FrameFormat, slot_count: u32, ) -> Self

As new but with an explicit slot count, for tests that want to force slot recycling and exercise the torn/stale-read drop path.

Source

pub fn frame_bytes(&self) -> usize

The frame size of one full frame in this ring’s format.

Source

pub fn on_frame<F>(&mut self, callback: F)
where F: Fn(Frame) + Send + Sync + 'static,

Register the per-frame callback the plugin under test would pass to ctx.vision.subscribe_frames. Replaces any prior callback.

Source

pub fn on_frame_arc(&mut self, callback: FrameCallback)

Register a callback as a pre-built FrameCallback (e.g. the exact Arc a plugin handed to the SDK).

Source

pub fn push_frame(&mut self, pixels: Vec<u8>)

Enqueue a raw pixel frame. The bytes must be at most one full frame (frame_bytes); a shorter slice is delivered as a partial frame, which is what a real engine does for a truncated capture.

Source

pub fn push_solid(&mut self, value: u8)

Enqueue a frame filled with one byte value (a flat colour), sized to a full frame. Handy for asserting the callback sees the right bytes.

Source

pub fn push_dir(&mut self, dir: impl AsRef<Path>) -> Result<usize>

Enqueue every *.bin / *.raw file in dir (sorted by name) as a frame, reading each file’s bytes verbatim. Returns the count enqueued.

Source

pub fn deliver_one(&mut self) -> bool

Deliver the next pending frame: write it into the ring, build its descriptor, resolve it through the seqlock, and invoke the callback. Returns true if a frame was delivered (a frame existed and resolved), false if the queue was empty. A frame that fails to resolve (a forced torn read) returns true for “consumed” but does not fire the callback.

Source

pub fn deliver_all(&mut self) -> usize

Deliver every pending frame in order. Returns the number delivered.

Source

pub fn detection_sink(&self) -> Arc<Mutex<Vec<CapturedDetection>>> ⓘ

The shared detection sink. Pass this into a plugin (or call capture directly) so detections the plugin would publish via ctx.vision.publish_detection are recorded here.

Source

pub fn capture(&self, batch: DetectionBatch)

Record a detection batch the plugin under test published, as if the engine received it. A test that cannot route the real publish call can invoke this from a stubbed publish path.

Source

pub fn captured_detections(&self) -> Vec<CapturedDetection> ⓘ

The captured detections in publish order. Returns a copy.

Source

pub fn clear_captured(&self)

Clear the captured detections.

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.

Source§

impl<T> Instrument for T

Source§

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

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

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> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<T> WithSubscriber for T

Source§

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

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

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