Struct EimBackend

Source
pub struct EimBackend {
    path: PathBuf,
    socket_path: PathBuf,
    tempdir: Option<TempDir>,
    socket: UnixStream,
    debug: bool,
    debug_callback: Option<DebugCallback>,
    _process: Child,
    model_info: Option<ModelInfo>,
    message_id: AtomicU32,
    model_parameters: ModelParameters,
}
Expand description

EIM backend implementation for socket-based communication

Fields§

§path: PathBuf

Path to the Edge Impulse model file (.eim)

§socket_path: PathBuf

Path to the Unix socket used for IPC

§tempdir: Option<TempDir>

Handle to the temporary directory for the socket (ensures cleanup)

§socket: UnixStream

Active Unix socket connection to the model process

§debug: bool

Enable debug logging of socket communications

§debug_callback: Option<DebugCallback>

Optional debug callback for receiving debug messages

§_process: Child

Handle to the model process (kept alive while model exists)

§model_info: Option<ModelInfo>

Cached model information received during initialization

§message_id: AtomicU32

Atomic counter for generating unique message IDs

§model_parameters: ModelParameters

Model parameters extracted from model info

Implementations§

Source§

impl EimBackend

Source

pub fn new(config: BackendConfig) -> Result<Self, EdgeImpulseError>

Create a new EIM backend

Source

fn ensure_executable<P: AsRef<Path>>(path: P) -> Result<(), EdgeImpulseError>

Ensure the model file has execution permissions for the current user

Source

fn connect_with_retry( socket_path: &Path, timeout: Duration, ) -> Result<UnixStream, EdgeImpulseError>

Connect to the socket with retry logic

Source

fn send_hello(&mut self) -> Result<(), EdgeImpulseError>

Send hello message to get model information

Source

fn next_message_id(&self) -> u32

Generate the next unique message ID

Source

pub fn set_debug_callback(&mut self, callback: DebugCallback)

Set the debug callback

Source

fn debug_message(&self, msg: &str)

Send a debug message if a callback is set

Source

fn classify( &mut self, input: &[f32], ) -> Result<InferenceResult, EdgeImpulseError>

Classify a single input

Trait Implementations§

Source§

impl InferenceBackend for EimBackend

Source§

fn new(config: BackendConfig) -> Result<Self, EdgeImpulseError>

Create a new backend instance
Source§

fn infer( &mut self, features: Vec<f32>, _debug: Option<bool>, ) -> Result<InferenceResponse, EdgeImpulseError>

Run inference on features
Source§

fn parameters(&self) -> Result<&ModelParameters, EdgeImpulseError>

Get model parameters
Source§

fn sensor_type(&self) -> Result<SensorType, EdgeImpulseError>

Get sensor type
Source§

fn input_size(&self) -> Result<usize, EdgeImpulseError>

Get input size
Source§

fn set_debug_callback(&mut self, callback: Box<dyn Fn(&str) + Send + Sync>)

Set debug callback
Source§

fn normalize_visual_anomaly( &self, anomaly: f32, max: f32, mean: f32, regions: &[(f32, u32, u32, u32, u32)], ) -> VisualAnomalyResult

Normalize visual anomaly results

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.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

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
§

impl<T> ErasedDestructor for T
where T: 'static,