/// Load an aliased version of a state type.
Load an aliased version of a state type.
Load an aliased version of a state type .
fn load_alias<S, Ser>(alias: Alias) -> Result<Option<S>>
where
    S: State<Ser>,
    Ser: Serialization,
{
    let alias_path = alias.path::<S>();
    match std::fs::read(&alias_path) {
        Err(e) => {
            match e.kind() {
                std::io::ErrorKind::NotFound => Ok(None),
                _ => Err(anyhow::Error::from(e)
                    .context(format!("while opening {}", alias_path.display()))),
            }
        }
        Ok(bytes) => S::from_json(bytes)
            .map(Some)
            .with_context(|| format!("while deserializing {}", alias_path.display())),
    }
}
fn load_alias < S , Ser > ( alias : Alias ) -> Result < Option < S > > where S : State < Ser > , Ser : Serialization , { let alias_path = alias . path :: < S > ( ) ; match std :: fs :: read ( & alias_path ) { Err ( e ) => { match e . kind ( ) { std :: io :: ErrorKind :: NotFound => Ok ( None ) , _ => Err ( anyhow :: Error :: from ( e ) . context ( format ! ( " " alias_path display ( ) ) ) ) , } } Ok ( bytes ) => S :: from_json ( bytes ) . map ( Some ) . with_context ( | | format ! ( " " alias_path display ( ) ) ) , } }
Load an aliased version of a state type.
Load an aliased version of a state type .
alias
Alias