pub enum ModelSource {
Path(PathBuf),
Memory(Arc<[u8]>),
}Expand description
Where to load an ONNX model from.
Every model-accepting builder takes impl Into<ModelSource>, so existing
path-based call sites keep working while callers can also pass raw model
bytes (e.g. from include_bytes! or decrypted at runtime):
use oar_ocr_core::core::ModelSource;
let from_path: ModelSource = "models/det.onnx".into();
let from_bytes: ModelSource = vec![0u8; 4].into();
assert!(from_path.as_path().is_some());
assert!(from_bytes.as_path().is_none());Variants§
Path(PathBuf)
Load from a file path (resolved through the auto-download cache where that feature applies).
Memory(Arc<[u8]>)
Load from in-memory ONNX bytes. Arc keeps clones cheap; models whose
weights live in external-data sidecar files cannot be loaded this way.
Implementations§
Source§impl ModelSource
impl ModelSource
Trait Implementations§
Source§impl Clone for ModelSource
impl Clone for ModelSource
Source§fn clone(&self) -> ModelSource
fn clone(&self) -> ModelSource
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ModelSource
impl Debug for ModelSource
Source§impl From<&'static [u8]> for ModelSource
impl From<&'static [u8]> for ModelSource
Source§fn from(bytes: &'static [u8]) -> ModelSource
fn from(bytes: &'static [u8]) -> ModelSource
Converts to this type from the input type.
Source§impl From<&ModelSource> for ModelSource
impl From<&ModelSource> for ModelSource
Source§fn from(source: &ModelSource) -> ModelSource
fn from(source: &ModelSource) -> ModelSource
Converts to this type from the input type.
Source§impl From<&Path> for ModelSource
impl From<&Path> for ModelSource
Source§fn from(p: &Path) -> ModelSource
fn from(p: &Path) -> ModelSource
Converts to this type from the input type.
Source§impl From<&PathBuf> for ModelSource
impl From<&PathBuf> for ModelSource
Source§fn from(p: &PathBuf) -> ModelSource
fn from(p: &PathBuf) -> ModelSource
Converts to this type from the input type.
Source§impl From<&str> for ModelSource
impl From<&str> for ModelSource
Source§fn from(p: &str) -> ModelSource
fn from(p: &str) -> ModelSource
Converts to this type from the input type.
Source§impl From<PathBuf> for ModelSource
impl From<PathBuf> for ModelSource
Source§fn from(p: PathBuf) -> ModelSource
fn from(p: PathBuf) -> ModelSource
Converts to this type from the input type.
Source§impl From<String> for ModelSource
impl From<String> for ModelSource
Source§fn from(p: String) -> ModelSource
fn from(p: String) -> ModelSource
Converts to this type from the input type.
Auto Trait Implementations§
impl Freeze for ModelSource
impl RefUnwindSafe for ModelSource
impl Send for ModelSource
impl Sync for ModelSource
impl Unpin for ModelSource
impl UnsafeUnpin for ModelSource
impl UnwindSafe for ModelSource
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.