Trait bpx::section::SectionData [−][src]
pub trait SectionData: Read + Write + Seek {
fn load_in_memory(&mut self) -> Result<Vec<u8>>;
fn size(&self) -> usize;
}
Expand description
Opaque variant intended to manipulate section data in the form of standard IO operations.
Required methods
fn load_in_memory(&mut self) -> Result<Vec<u8>>
fn load_in_memory(&mut self) -> Result<Vec<u8>>
Loads this section into memory.
Errors
An Error is returned if the section could not be loaded.
Examples
use bpx::encoder::Encoder;
use bpx::header::SectionHeader;
use bpx::Interface;
let mut file = Encoder::new(Vec::<u8>::new()).unwrap();
let handle = file.create_section(SectionHeader::new()).unwrap();
let section = file.open_section(handle).unwrap();
let data = section.load_in_memory().unwrap();
assert_eq!(data.len(), 0);
Returns the current size of this section.
Examples
use bpx::encoder::Encoder;
use bpx::header::SectionHeader;
use bpx::Interface;
let mut file = Encoder::new(Vec::<u8>::new()).unwrap();
let handle = file.create_section(SectionHeader::new()).unwrap();
let section = file.open_section(handle).unwrap();
assert_eq!(section.size(), 0);