pub enum Header {
V0(HeaderV0),
V3(HeaderV3),
}Expand description
Standard Android boot image header for versions 0 through 4
Variants§
Implementations§
Source§impl Header
impl Header
Sourcepub fn parse<R: Read + Seek>(reader: &mut R) -> Result<Self, Error>
pub fn parse<R: Read + Seek>(reader: &mut R) -> Result<Self, Error>
Parses a standard Android boot image header from a reader.
§Errors
This returns an error if reading fails or if the header is invalid.
Examples found in repository?
examples/extract-kernel.rs (line 12)
10fn main() {
11 let mut r = BufReader::new(File::open("boot_a.img").unwrap());
12 let hdr = Header::parse(&mut r).unwrap();
13 println!("{hdr:#?}");
14
15 println!("kernel position: {}", hdr.kernel_position());
16 let mut w = BufWriter::new(File::create("boot_a_kernel").unwrap());
17 let r = r.get_mut();
18 r.seek(SeekFrom::Start(hdr.kernel_position() as u64))
19 .unwrap();
20 io::copy(&mut r.take(hdr.kernel_size().into()), w.get_mut()).unwrap();
21}Sourcepub fn write<W: Write>(&self, writer: &mut W) -> Result<(), Error>
pub fn write<W: Write>(&self, writer: &mut W) -> Result<(), Error>
Serializes a standard Android boot image header to a writer.
Note that you must write the kernel, ramdisk, etc. yourself.
§Errors
This forwards errors from writer.
Sourcepub const fn header_version(&self) -> u32
pub const fn header_version(&self) -> u32
Returns the boot image header’s version number.
Sourcepub const fn osversionpatch(&self) -> OsVersionPatch
pub const fn osversionpatch(&self) -> OsVersionPatch
Returns the boot image header’s OS version and patch level.
Sourcepub const fn kernel_position(&self) -> usize
pub const fn kernel_position(&self) -> usize
Returns the kernel’s position in the boot image.
Examples found in repository?
examples/extract-kernel.rs (line 15)
10fn main() {
11 let mut r = BufReader::new(File::open("boot_a.img").unwrap());
12 let hdr = Header::parse(&mut r).unwrap();
13 println!("{hdr:#?}");
14
15 println!("kernel position: {}", hdr.kernel_position());
16 let mut w = BufWriter::new(File::create("boot_a_kernel").unwrap());
17 let r = r.get_mut();
18 r.seek(SeekFrom::Start(hdr.kernel_position() as u64))
19 .unwrap();
20 io::copy(&mut r.take(hdr.kernel_size().into()), w.get_mut()).unwrap();
21}Sourcepub const fn kernel_size(&self) -> u32
pub const fn kernel_size(&self) -> u32
Returns the kernel’s size.
Examples found in repository?
examples/extract-kernel.rs (line 20)
10fn main() {
11 let mut r = BufReader::new(File::open("boot_a.img").unwrap());
12 let hdr = Header::parse(&mut r).unwrap();
13 println!("{hdr:#?}");
14
15 println!("kernel position: {}", hdr.kernel_position());
16 let mut w = BufWriter::new(File::create("boot_a_kernel").unwrap());
17 let r = r.get_mut();
18 r.seek(SeekFrom::Start(hdr.kernel_position() as u64))
19 .unwrap();
20 io::copy(&mut r.take(hdr.kernel_size().into()), w.get_mut()).unwrap();
21}Sourcepub const fn ramdisk_position(&self) -> usize
pub const fn ramdisk_position(&self) -> usize
Returns the ramdisk’s position in the boot image.
Sourcepub const fn ramdisk_size(&self) -> u32
pub const fn ramdisk_size(&self) -> u32
Returns the ramdisk’s size.
Trait Implementations§
impl Eq for Header
impl StructuralPartialEq for Header
Auto Trait Implementations§
impl Freeze for Header
impl RefUnwindSafe for Header
impl Send for Header
impl Sync for Header
impl Unpin for Header
impl UnwindSafe for Header
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more