Skip to main content

SmartSerde

Trait SmartSerde 

Source
pub trait SmartSerde: Serialize + DeserializeOwned {
    // Provided methods
    fn to_file(
        &self,
        file_path: impl AsRef<Path>,
        override_existing: bool,
    ) -> Result<()> { ... }
    fn from_file_typed(
        file_path: impl AsRef<Path>,
    ) -> Result<Self, SerdeFileError> { ... }
    fn from_file(file_path: impl AsRef<Path>, name: &str) -> Result<Self> { ... }
    fn from_str(contents: String, format: &str, name: &str) -> Result<Self> { ... }
    fn has_schema_path(&self, _online: bool) -> Option<Result<PathBuf>> { ... }
}

Provided Methods§

Source

fn to_file( &self, file_path: impl AsRef<Path>, override_existing: bool, ) -> Result<()>

Source

fn from_file_typed(file_path: impl AsRef<Path>) -> Result<Self, SerdeFileError>

Loads and deserializes data from a file with typed error handling.

This function differentiates between file errors (e.g., file not found) and parse errors (e.g., invalid JSON/YAML/TOML syntax) using SerdeFileError.

§Arguments
  • file_path - Path to the file to load
  • _name - Name of the data type being loaded (for error messages, currently unused)
§Returns
  • Ok(Self) - Successfully loaded and parsed data
  • Err(SerdeFileError) - Typed error indicating whether it was a file or parse error
Source

fn from_file(file_path: impl AsRef<Path>, name: &str) -> Result<Self>

Source

fn from_str(contents: String, format: &str, name: &str) -> Result<Self>

Source

fn has_schema_path(&self, _online: bool) -> Option<Result<PathBuf>>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl<T> SmartSerde for BTreeMap<String, (T, T)>

Implementors§