pub trait FromVersion<T>: Sized {
// Required method
fn convert(self) -> T;
}Expand description
Trait for converting from a versioned struct to the current struct.
This trait must be implemented for each version struct to define how it converts to the current version of the struct.
§Example
use serde_versioned::FromVersion;
struct User { name: String, age: u32 }
struct UserV1 { name: String }
impl FromVersion<User> for UserV1 {
fn convert(self) -> User {
User { name: self.name, age: 0 }
}
}Required Methods§
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.