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§
Sourcefn set_path(
&self,
fimg: &mut FileImage,
path: &str,
) -> Result<(), Box<dyn Error>>
fn set_path( &self, fimg: &mut FileImage, path: &str, ) -> Result<(), Box<dyn Error>>
Check syntax and set the path for this file image
Sourcefn get_load_address(&self, fimg: &FileImage) -> usize
fn get_load_address(&self, fimg: &FileImage) -> usize
Get load address for this file image, if applicable.
Sourcefn unpack(&self, fimg: &FileImage) -> Result<UnpackedData, Box<dyn Error>>
fn unpack(&self, fimg: &FileImage) -> Result<UnpackedData, Box<dyn Error>>
automatically select an unpacking strategy based on the file image metadata
Sourcefn pack_raw(
&self,
fimg: &mut FileImage,
dat: &[u8],
) -> Result<(), Box<dyn Error>>
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.
Sourcefn unpack_raw(
&self,
fimg: &FileImage,
trunc: bool,
) -> Result<Vec<u8>, Box<dyn Error>>
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.
Sourcefn pack_bin(
&self,
fimg: &mut FileImage,
dat: &[u8],
load_addr: Option<usize>,
trailing: Option<&[u8]>,
) -> Result<(), Box<dyn Error>>
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.
Sourcefn unpack_bin(&self, fimg: &FileImage) -> Result<Vec<u8>, Box<dyn Error>>
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
Sourcefn pack_txt(
&self,
fimg: &mut FileImage,
txt: &str,
) -> Result<(), Box<dyn Error>>
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.
Sourcefn unpack_txt(&self, fimg: &FileImage) -> Result<String, Box<dyn Error>>
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.
Sourcefn pack_tok(
&self,
fimg: &mut FileImage,
tok: &[u8],
lang: ItemType,
trailing: Option<&[u8]>,
) -> Result<(), Box<dyn Error>>
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
Sourcefn unpack_tok(&self, fimg: &FileImage) -> Result<Vec<u8>, Box<dyn Error>>
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
Sourcefn pack_rec_str(
&self,
fimg: &mut FileImage,
json: &str,
) -> Result<(), Box<dyn Error>>
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
Sourcefn unpack_rec_str(
&self,
fimg: &FileImage,
rec_len: Option<usize>,
indent: Option<u16>,
) -> Result<String, Box<dyn Error>>
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
Provided Methods§
Sourcefn pack(
&self,
_fimg: &mut FileImage,
_dat: &[u8],
_load_addr: Option<usize>,
) -> Result<(), Box<dyn Error>>
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
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".