pub fn decode(f: &str) -> Result<KeyFile, Error> {
        let buf1 = f.to_string();
        let buf2 = f.to_string();
        let mut ver = 0;

        let kf = json::decode::<SerializableKeyFileCore>(&buf1)
            .and_then(|core| {
                ver = core.version;
                Ok(core.into())
            })
            .or_else(|_| {
                json::decode::<SerializableKeyFileHD>(&buf2).and_then(|hd| {
                    ver = hd.version;
                    Ok(hd.into())
                })
            })
            .map_err(Error::from)?;

        if !SUPPORTED_VERSIONS.contains(&ver) {
            return Err(Error::UnsupportedVersion(ver));
        }

        Ok(kf)
    }
/// Decode `Keyfile` from JSON
/// Handles different variants of `crypto` section
///
Decode `Keyfile` from JSON
Handles different variants of `crypto` section
Decode ` Keyfile ` from JSON Handles different variants of ` crypto ` section
pub fn decode(f: &str) -> Result<KeyFile, Error> {
        let buf1 = f.to_string();
        let buf2 = f.to_string();
        let mut ver = 0;
        let kf = json::decode::<SerializableKeyFileCore>(&buf1)
            .and_then(|core| {
                ver = core.version;
                Ok(core.into())
            })
            .or_else(|_| {
                json::decode::<SerializableKeyFileHD>(&buf2).and_then(|hd| {
                    ver = hd.version;
                    Ok(hd.into())
                })
            })
            .map_err(Error::from)?;
        if !SUPPORTED_VERSIONS.contains(&ver) {
            return Err(Error::UnsupportedVersion(ver));
        }
        Ok(kf)
    }
pub fn decode ( f : & str ) -> Result < KeyFile , Error > { let buf1 = f . to_string ( ) ; let buf2 = f . to_string ( ) ; let mut ver = 0 ; let kf = json :: decode :: < SerializableKeyFileCore > ( & buf1 ) . and_then ( | core | { ver = core . version ; Ok ( core . into ( ) ) } ) . or_else ( | _ | { json :: decode :: < SerializableKeyFileHD > ( & buf2 ) . and_then ( | hd | { ver = hd . version ; Ok ( hd . into ( ) ) } ) } ) . map_err ( Error :: from ) ? ; if ! SUPPORTED_VERSIONS . contains ( & ver ) { return Err ( Error :: UnsupportedVersion ( ver ) ) ; } Ok ( kf ) }
Decode `Keyfile` from JSON
Handles different variants of `crypto` section
Decode ` Keyfile ` from JSON Handles different variants of ` crypto ` section
f
&str
f
&str