pub struct Model<'lib> { /* private fields */ }Expand description
A loaded TFLite model.
Models can be created from in-memory bytes or from a file. The model
data is kept alive for the lifetime of the Model.
Implementations§
Source§impl<'lib> Model<'lib>
impl<'lib> Model<'lib>
Sourcepub fn from_bytes(lib: &'lib Library, data: impl Into<Vec<u8>>) -> Result<Self>
pub fn from_bytes(lib: &'lib Library, data: impl Into<Vec<u8>>) -> Result<Self>
Create a Model from raw bytes.
Takes ownership of the provided byte buffer and passes a pointer to
the underlying TFLite C API. The data is kept alive for the
lifetime of the returned Model.
Sourcepub fn from_file(lib: &'lib Library, path: impl AsRef<Path>) -> Result<Self>
pub fn from_file(lib: &'lib Library, path: impl AsRef<Path>) -> Result<Self>
Create a Model by reading a file from disk.
Reads the entire file into memory, then delegates to
Model::from_bytes.
§Errors
Returns an error if the file cannot be read (I/O error) or if the
TFLite C API fails to parse the model bytes (returns null).
Trait Implementations§
Auto Trait Implementations§
impl<'lib> Freeze for Model<'lib>
impl<'lib> !RefUnwindSafe for Model<'lib>
impl<'lib> !Send for Model<'lib>
impl<'lib> !Sync for Model<'lib>
impl<'lib> Unpin for Model<'lib>
impl<'lib> UnsafeUnpin for Model<'lib>
impl<'lib> !UnwindSafe for Model<'lib>
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