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
impl EimBackend
Sourcepub fn new(config: BackendConfig) -> Result<Self, EdgeImpulseError>
pub fn new(config: BackendConfig) -> Result<Self, EdgeImpulseError>
Create a new EIM backend
Sourcefn ensure_executable<P: AsRef<Path>>(path: P) -> Result<(), EdgeImpulseError>
fn ensure_executable<P: AsRef<Path>>(path: P) -> Result<(), EdgeImpulseError>
Ensure the model file has execution permissions for the current user
Sourcefn connect_with_retry(
socket_path: &Path,
timeout: Duration,
) -> Result<UnixStream, EdgeImpulseError>
fn connect_with_retry( socket_path: &Path, timeout: Duration, ) -> Result<UnixStream, EdgeImpulseError>
Connect to the socket with retry logic
Sourcefn send_hello(&mut self) -> Result<(), EdgeImpulseError>
fn send_hello(&mut self) -> Result<(), EdgeImpulseError>
Send hello message to get model information
Sourcefn next_message_id(&self) -> u32
fn next_message_id(&self) -> u32
Generate the next unique message ID
Sourcepub fn set_debug_callback(&mut self, callback: DebugCallback)
pub fn set_debug_callback(&mut self, callback: DebugCallback)
Set the debug callback
Sourcefn debug_message(&self, msg: &str)
fn debug_message(&self, msg: &str)
Send a debug message if a callback is set
Sourcefn classify(
&mut self,
input: &[f32],
) -> Result<InferenceResult, EdgeImpulseError>
fn classify( &mut self, input: &[f32], ) -> Result<InferenceResult, EdgeImpulseError>
Classify a single input