1 //! A plugin with a foreign runtime, for the launch check.2 //!3 //! The check reads the process environment, so a test cannot change the4 //! variable from inside its own process without `unsafe`. This binary owns a5 //! process and lets the test set the variable before it starts.6 7 use std::sync::Arc;8 9 use inf3r_plugin_sdk::capability::{Failure, Report, Request};10 use inf3r_plugin_sdk::emitter::Emitter;11 use inf3r_plugin_sdk::serve::{Plugin, RuntimeVersion};12 use inf3r_proto::body::{Catalogue, ErrorCode, Grant, Ready, Target};13 14 /// The plugin whose binding names a runtime.15 struct Probe;16 17 impl Plugin for Probe {18 fn max_inflight(&self) -> u16 {19 120 }21 22 fn runtime(&self) -> Option<RuntimeVersion> {23 Some(RuntimeVersion {24 name: "probe".to_string(),25 version: "1.0".to_string(),26 })27 }28 29 fn catalogue(&self) -> Catalogue {30 Catalogue {31 target: Target {32 id: "cpu".to_string(),33 backend: "probe".to_string(),34 arch: vec![std::env::consts::ARCH.to_string()],35 devices: 0,36 vram_mb: Vec::new(),37 },38 models: Vec::new(),39 runtime: None,40 cache: None,41 }42 }43 44 fn load(&self, _grant: &Grant) -> Result<Ready, Failure> {45 Ok(Ready {46 load_ms: 0,47 cache_fingerprint: None,48 })49 }50 51 fn run(52 &self,53 _capability: &str,54 _req: Request<'_>,55 _out: &mut dyn Emitter,56 ) -> Result<Report, Failure> {57 Err(Failure::new(ErrorCode::Internal, "the probe has no model"))58 }59 }60 61 fn main() -> std::io::Result<()> {62 inf3r_plugin_sdk::launch(Arc::new(Probe))63 }