Skip to main content

Packing

Trait Packing 

Source
pub trait Packing {
Show 18 methods // Required methods fn set_path( &self, fimg: &mut FileImage, path: &str, ) -> Result<(), Box<dyn Error>>; fn get_load_address(&self, fimg: &FileImage) -> usize; fn unpack(&self, fimg: &FileImage) -> Result<UnpackedData, Box<dyn Error>>; fn pack_raw( &self, fimg: &mut FileImage, dat: &[u8], ) -> Result<(), Box<dyn Error>>; fn unpack_raw( &self, fimg: &FileImage, trunc: bool, ) -> Result<Vec<u8>, Box<dyn Error>>; fn pack_bin( &self, fimg: &mut FileImage, dat: &[u8], load_addr: Option<usize>, trailing: Option<&[u8]>, ) -> Result<(), Box<dyn Error>>; fn unpack_bin(&self, fimg: &FileImage) -> Result<Vec<u8>, Box<dyn Error>>; fn pack_txt( &self, fimg: &mut FileImage, txt: &str, ) -> Result<(), Box<dyn Error>>; fn unpack_txt(&self, fimg: &FileImage) -> Result<String, Box<dyn Error>>; fn pack_tok( &self, fimg: &mut FileImage, tok: &[u8], lang: ItemType, trailing: Option<&[u8]>, ) -> Result<(), Box<dyn Error>>; fn unpack_tok(&self, fimg: &FileImage) -> Result<Vec<u8>, Box<dyn Error>>; fn pack_rec_str( &self, fimg: &mut FileImage, json: &str, ) -> Result<(), Box<dyn Error>>; fn unpack_rec_str( &self, fimg: &FileImage, rec_len: Option<usize>, indent: Option<u16>, ) -> Result<String, Box<dyn Error>>; fn pack_rec( &self, fimg: &mut FileImage, recs: &Records, ) -> Result<(), Box<dyn Error>>; fn unpack_rec( &self, fimg: &FileImage, rec_len: Option<usize>, ) -> Result<Records, Box<dyn Error>>; // Provided methods fn pack( &self, _fimg: &mut FileImage, _dat: &[u8], _load_addr: Option<usize>, ) -> Result<(), Box<dyn Error>> { ... } fn pack_apple_single( &self, _fimg: &mut FileImage, _dat: &[u8], _load_addr: Option<usize>, ) -> Result<(), Box<dyn Error>> { ... } fn unpack_apple_single( &self, _fimg: &FileImage, ) -> Result<Vec<u8>, Box<dyn Error>> { ... }
}
Expand description

Trait implemented by the Packer delegates of FileImage. Usually not called directly, because FileImage provides wrappers.

Required Methods§

Source

fn set_path( &self, fimg: &mut FileImage, path: &str, ) -> Result<(), Box<dyn Error>>

Check syntax and set the path for this file image

Source

fn get_load_address(&self, fimg: &FileImage) -> usize

Get load address for this file image, if applicable.

Source

fn unpack(&self, fimg: &FileImage) -> Result<UnpackedData, Box<dyn Error>>

automatically select an unpacking strategy based on the file image metadata

Source

fn pack_raw( &self, fimg: &mut FileImage, dat: &[u8], ) -> Result<(), Box<dyn Error>>

Pack raw byte stream into file image. Headers used by the file system are not automatically inserted. If the file system has explicit typing, the type is set to text.

Source

fn unpack_raw( &self, fimg: &FileImage, trunc: bool, ) -> Result<Vec<u8>, Box<dyn Error>>

Get the raw bytestream, including any header used by the file system. The byte stream will extend to end of block unless trunc==true. Setting trunc==true only works if the EOF is stored in the directory.

Source

fn pack_bin( &self, fimg: &mut FileImage, dat: &[u8], load_addr: Option<usize>, trailing: Option<&[u8]>, ) -> Result<(), Box<dyn Error>>

Pack bytes into file image, if file system uses a header it is added. The load address will be checked for validity, if not used by FS it must be None.

Source

fn unpack_bin(&self, fimg: &FileImage) -> Result<Vec<u8>, Box<dyn Error>>

get bytes from file image, if file system uses a header it is stripped

Source

fn pack_txt( &self, fimg: &mut FileImage, txt: &str, ) -> Result<(), Box<dyn Error>>

Convert UTF8 with either LF or CRLF to the file system’s text format. This returns an error if the conversion would result in any loss of data.

Source

fn unpack_txt(&self, fimg: &FileImage) -> Result<String, Box<dyn Error>>

Convert the file system’s text format to UTF8 with LF. This always succeeds because the underlying text converters will replace unknown characters with ASCII NULL.

Source

fn pack_tok( &self, fimg: &mut FileImage, tok: &[u8], lang: ItemType, trailing: Option<&[u8]>, ) -> Result<(), Box<dyn Error>>

pack language tokens into file image, if file system uses a header it is added

Source

fn unpack_tok(&self, fimg: &FileImage) -> Result<Vec<u8>, Box<dyn Error>>

get language tokens from file image, if file system uses a header it is stripped

Source

fn pack_rec_str( &self, fimg: &mut FileImage, json: &str, ) -> Result<(), Box<dyn Error>>

turn JSON representation of random access text into a file image

Source

fn unpack_rec_str( &self, fimg: &FileImage, rec_len: Option<usize>, indent: Option<u16>, ) -> Result<String, Box<dyn Error>>

turn the file image into JSON representation of random access text

Source

fn pack_rec( &self, fimg: &mut FileImage, recs: &Records, ) -> Result<(), Box<dyn Error>>

turn random access text records into a file image

Source

fn unpack_rec( &self, fimg: &FileImage, rec_len: Option<usize>, ) -> Result<Records, Box<dyn Error>>

turn the file image into random access text records

Provided Methods§

Source

fn pack( &self, _fimg: &mut FileImage, _dat: &[u8], _load_addr: Option<usize>, ) -> Result<(), Box<dyn Error>>

automatically select a packing strategy by analyzing the data

Source

fn pack_apple_single( &self, _fimg: &mut FileImage, _dat: &[u8], _load_addr: Option<usize>, ) -> Result<(), Box<dyn Error>>

turn an AppleSingle file image into a native file image

Source

fn unpack_apple_single( &self, _fimg: &FileImage, ) -> Result<Vec<u8>, Box<dyn Error>>

turn the native file image into an AppleSingle file image

Dyn Compatibility§

This trait is dyn compatible.

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

Implementors§

Source§

impl Packing for a2kit::fs::dos3x::Packer

Source§

impl Packing for a2kit::fs::prodos::Packer

Source§

impl Packing for a2kit::fs::pascal::Packer

Source§

impl Packing for a2kit::fs::cpm::Packer

Source§

impl Packing for a2kit::fs::fat::Packer