pub fn extract_header_as<'de, T>(
        &self,
        data: &'de [u8],
    ) -> Result<(T, Encoding), ImperatorError>
    where
        T: Deserialize<'de>,
    {
        let data = skip_save_prefix(&data);
        let mut cursor = Cursor::new(data);
        let offset = match detect_encoding(&mut cursor)? {
            BodyEncoding::Plain => data.len(),
            BodyEncoding::Zip(zip) => zip.offset() as usize,
        };

        let data = &data[..offset];
        if sniff_is_binary(data) {
            let res = BinaryDeserializer::builder_flavor(ImperatorFlavor)
                .on_failed_resolve(self.on_failed_resolve)
                .from_slice(data, &TokenLookup)?;
            Ok((res, Encoding::Standard))
        } else {
            // allow uncompressed text as TextZip even though the game doesn't produce said format
            let res = TextDeserializer::from_utf8_slice(data)?;
            Ok((res, Encoding::Debug))
        }
    }
/// Extract the header from the save as a custom type
Extract the header from the save as a custom type
Extract the header from the save as a custom type
pub fn extract_header_as<'de, T>(
        &self,
        data: &'de [u8],
    ) -> Result<(T, Encoding), ImperatorError>
    where
        T: Deserialize<'de>,
    {
        let data = skip_save_prefix(&data);
        let mut cursor = Cursor::new(data);
        let offset = match detect_encoding(&mut cursor)? {
            BodyEncoding::Plain => data.len(),
            BodyEncoding::Zip(zip) => zip.offset() as usize,
        };
        let data = &data[..offset];
        if sniff_is_binary(data) {
            let res = BinaryDeserializer::builder_flavor(ImperatorFlavor)
                .on_failed_resolve(self.on_failed_resolve)
                .from_slice(data, &TokenLookup)?;
            Ok((res, Encoding::Standard))
        } else {
            // allow uncompressed text as TextZip even though the game doesn't produce said format
            let res = TextDeserializer::from_utf8_slice(data)?;
            Ok((res, Encoding::Debug))
        }
    }
pub fn extract_header_as < ' de , T > ( & self , data : & ' de [ u8 ] , ) -> Result < ( T , Encoding ) , ImperatorError > where T : Deserialize < ' de > , { let data = skip_save_prefix ( & data ) ; let mut cursor = Cursor :: new ( data ) ; let offset = match detect_encoding ( & mut cursor ) ? { BodyEncoding :: Plain => data . len ( ) , BodyEncoding :: Zip ( zip ) => zip . offset ( ) as usize , } ; let data = & data [ .. offset ] ; if sniff_is_binary ( data ) { let res = BinaryDeserializer :: builder_flavor ( ImperatorFlavor ) . on_failed_resolve ( self . on_failed_resolve ) . from_slice ( data , & TokenLookup ) ? ; Ok ( ( res , Encoding :: Standard ) ) } else { // allow uncompressed text as TextZip even though the game doesn't produce said format let res = TextDeserializer :: from_utf8_slice ( data ) ? ; Ok ( ( res , Encoding :: Debug ) ) } }
Extract the header from the save as a custom type
Extract the header from the save as a custom type
&self
data
&'de [u8]
&self
data
&'de [u8]