Trait thorin::Session

source ·
pub trait Session<Relocations> {
    // Required methods
    fn alloc_data<'session>(&'session self, data: Vec<u8>) -> &'session [u8] ;
    fn alloc_relocation<'session>(
        &'session self,
        data: Relocations
    ) -> &'session Relocations;
    fn read_input<'session>(
        &'session self,
        path: &Path
    ) -> Result<&'session [u8]>;

    // Provided method
    fn alloc_owned_cow<'input, 'session: 'input>(
        &'session self,
        data: Cow<'input, [u8]>
    ) -> &'input [u8]  { ... }
}
Expand description

Session is expected to be implemented by users of thorin, allowing users of thorin to decide how to manage data, rather than thorin having arenas internally.

Required Methods§

source

fn alloc_data<'session>(&'session self, data: Vec<u8>) -> &'session [u8]

Returns a reference to data’s contents with lifetime 'session.

source

fn alloc_relocation<'session>( &'session self, data: Relocations ) -> &'session Relocations

Returns a reference to relocation with lifetime 'session.

source

fn read_input<'session>(&'session self, path: &Path) -> Result<&'session [u8]>

Returns a reference to contents of file at path with lifetime 'session.

Provided Methods§

source

fn alloc_owned_cow<'input, 'session: 'input>( &'session self, data: Cow<'input, [u8]> ) -> &'input [u8]

Returns a reference to data’s contents with lifetime 'input.

If Cow is borrowed, then return the contained reference ('input). If Cow is owned, then calls alloc_data to return a reference of lifetime 'session, which is guaranteed to be longer than 'input, so can be returned.

Implementors§