[][src]Trait mozpdb::Source

pub trait Source<'s>: Debug {
    fn view(
        &mut self,
        slices: &[SourceSlice]
    ) -> Result<Box<dyn SourceView<'s>>, Error>; }

The pdb crate accesses PDB files via the pdb::Source trait.

This library is written with zero-copy in mind. Sources provide SourceViews which need not outlive their parent, supporting implementations of e.g. memory mapped files.

PDB files are "multi-stream files" (MSF) under the hood. MSFs have various layers of indirection, but ultimately the MSF code asks a Source to view a series of { offset, size } records, which the Source provides as a contiguous &[u8].

Default

There is a default Source implementation for std::io::Read + std::io::Seek + std::fmt::Debug, allowing a std::fs::File to be treated as pdb::Source. This implementation provides views by allocating a buffer, seeking, and reading the contents into that buffer.

Alignment

The requested offsets will always be aligned to the MSF's page size, which is always a power of two and is usually (but not always) 4096 bytes. The requested sizes will also be multiples of the page size, except for the size of the final SourceSlice, which may be smaller.

PDB files are specified as always being a multiple of the page size, so Source implementations are free to e.g. map whole pages and return a sub-slice of the requested length.

Required methods

fn view(
    &mut self,
    slices: &[SourceSlice]
) -> Result<Box<dyn SourceView<'s>>, Error>

Provides a contiguous view of the source file composed of the requested position(s).

Note that the SourceView's as_slice() method cannot fail, so view() is the time to raise IO errors.

Loading content...

Implementors

impl<'s, T> Source<'s> for T where
    T: Read + Seek + Debug + 's, 
[src]

Loading content...