INNER CODE UNIT · Rust
from_str
lanterndata/lantern · lantern_cli/src/embeddings/core/mod.rs:34
fn from_str(input: &str) -> Result<Runtime, anyhow::Error> {
match input {
"ort" => Ok(Runtime::Ort),
"openai" => Ok(Runtime::OpenAi),
"cohere" => Ok(Runtime::Cohere),
_ => anyhow::bail!("Invalid runtime {input}"),
}
}
}
impl TryFrom<&str> for Runtime {
type Error = anyhow::Error;
fn try_from(value: &str) -> Result<Self, Self::Error> {
Self::from_str(value)
}
}
impl ToString for Runtime {