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: PathBufPath to the Edge Impulse model file (.eim)
socket_path: PathBufPath to the Unix socket used for IPC
tempdir: Option<TempDir>Handle to the temporary directory for the socket (ensures cleanup)
socket: UnixStreamActive Unix socket connection to the model process
debug: boolEnable debug logging of socket communications
debug_callback: Option<DebugCallback>Optional debug callback for receiving debug messages
_process: ChildHandle to the model process (kept alive while model exists)
model_info: Option<ModelInfo>Cached model information received during initialization
message_id: AtomicU32Atomic counter for generating unique message IDs
model_parameters: ModelParametersModel 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