pub struct ModuleRecord { /* private fields */ }Expand description
A non-generic record holding a module’s parameters.
Obtain one from a module with Module::into_record, then either save it
(save / into_bytes) or apply it back with
Module::load_record. Load-time behavior is
configured with the builder methods; they are ignored when saving.
The save-side dtype is intentionally not configurable: use module.cast(dtype) before
taking the record. The record stores whatever dtype the module currently holds.
Implementations§
Source§impl ModuleRecord
impl ModuleRecord
Sourcepub fn with_dtype_policy(self, policy: DTypePolicy) -> Self
pub fn with_dtype_policy(self, policy: DTypePolicy) -> Self
Set the dtype policy used when loading into a module.
Sourcepub fn cast_to_module_dtype(self) -> Self
pub fn cast_to_module_dtype(self) -> Self
Cast the record’s data to the module parameter dtypes on load.
Sugar for with_dtype_policy(DTypePolicy::CastToModule).
Sourcepub fn allow_partial(self, allow: bool) -> Self
pub fn allow_partial(self, allow: bool) -> Self
Allow loading even when some module parameters are absent from the record.
Sourcepub fn into_bytes(self) -> Result<Bytes, RecordError>
pub fn into_bytes(self) -> Result<Bytes, RecordError>
Serialize the record to an in-memory burnpack byte buffer.
Sourcepub fn from_bytes(bytes: Bytes) -> Result<Self, RecordError>
pub fn from_bytes(bytes: Bytes) -> Result<Self, RecordError>
Reconstruct a record from an in-memory burnpack byte buffer.
Trait Implementations§
Source§impl Clone for ModuleRecord
impl Clone for ModuleRecord
Source§fn clone(&self) -> ModuleRecord
fn clone(&self) -> ModuleRecord
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !RefUnwindSafe for ModuleRecord
impl !UnwindSafe for ModuleRecord
impl Freeze for ModuleRecord
impl Send for ModuleRecord
impl Sync for ModuleRecord
impl Unpin for ModuleRecord
impl UnsafeUnpin for ModuleRecord
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
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> 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>
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>
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 more