pub trait Session<Relocations> {
fn alloc_data<'session>(&'session self, data: Vec<u8>) -> &'session [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [u8]
;
fn alloc_relocation<'session>(
&'session self,
data: Relocations
) -> &'session Relocations;
fn read_input<'session>(
&'session self,
path: &Path
) -> Result<&'session [u8]>;
fn alloc_owned_cow<'input, 'session: 'input>(
&'session self,
data: Cow<'input, [u8]>
) -> &'input [u8]ⓘNotable traits for &[u8]impl Read for &[u8]impl Write for &mut [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
Returns a reference to data
’s contents with lifetime 'session
.
fn alloc_relocation<'session>(
&'session self,
data: Relocations
) -> &'session Relocations
fn alloc_relocation<'session>(
&'session self,
data: Relocations
) -> &'session Relocations
Returns a reference to relocation
with lifetime 'session
.
fn read_input<'session>(&'session self, path: &Path) -> Result<&'session [u8]>
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
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.