Expand description
Encodes and decodes Little Fighter 2 (LF2) data files.
§Examples
§Encode
ⓘ
use lf2_codec::{DataEncoder, EncodeError};
const CHARACTER_DAT_ENCODED: &[u8] = b"\
This is sample data as bytes. \
The first 123 bytes are ignored during decoding, the rest are decoded using a caesar cipher. \
\xab\xc6\xaf\xd5\xc0\xd4\xa7\xcc\xcc\xcf\xb3\
\xe1\xc6\xb5\xca\x83\x93\x97\xdf\xe4\xe2\xac\
\xdb\xab\xc6\xc0\xd9\xd4\xad\xe3\xd2\xa5";
let data = "<bmp_begin>name: Azriel<bmp_end>";
let encoded = DataEncoder::encode(data.as_bytes())?;
assert_eq!(CHARACTER_DAT_ENCODED, encoded);
§Decode
ⓘ
use lf2_codec::{DataDecoder, DecodeError};
const CHARACTER_DAT_ENCODED: &[u8] = b"\
This is sample data as bytes. \
The first 123 bytes are ignored during decoding, the rest are decoded using a caesar cipher. \
\xab\xc6\xaf\xd5\xc0\xd4\xa7\xcc\xcc\xcf\xb3\
\xe1\xc6\xb5\xca\x83\x93\x97\xdf\xe4\xe2\xac\
\xdb\xab\xc6\xc0\xd9\xd4\xad\xe3\xd2\xa5";
let decoded = DataDecoder::decode(CHARACTER_DAT_ENCODED)?;
let expected = "<bmp_begin>name: Azriel<bmp_end>";
assert_eq!(expected, String::from_utf8_lossy(&decoded));
Structs§
- Data
Decoder - Decodes object data from LF2.
- Data
Encoder - Encodes data that the LF2 application may read.
- Decode
Error - Error occurred reading from the stream to decode.
- Encode
Error - Error occurred reading from the stream to encode.
Enums§
- Error
- Error that occurs when reading or writing to a stream.
Constants§
- CAESAR_
CIPHER - Key used to shift the ascii code of each object.
- DATA_
HEADER - Data used to fill the first 123 bytes of the data file. Strictly 123 bytes long.