pub struct MappedOption<'a, T: MemoryMapped<'a>> { /* private fields */ }Expand description
An optional immutable memory-mapped structure.
This is compatible with the serialization format of Option of the same type.
§Examples
use simple_sds_sbwt::serialize::{MappedOption, MappedSlice, MappingMode, MemoryMap, MemoryMapped, Serialize};
use simple_sds_sbwt::serialize;
use std::fs;
let some: Option<Vec<u64>> = Some(vec![123, 456, 789]);
let filename = serialize::temp_file_name("mapped-option");
serialize::serialize_to(&some, &filename);
let map = MemoryMap::new(&filename, MappingMode::ReadOnly).unwrap();
let mapped = MappedOption::<MappedSlice<u64>>::new(&map, 0).unwrap();
assert_eq!(mapped.unwrap().as_ref(), some.unwrap().as_slice());
drop(mapped); drop(map);
fs::remove_file(&filename).unwrap();Implementations§
Source§impl<'a, T: MemoryMapped<'a>> MappedOption<'a, T>
impl<'a, T: MemoryMapped<'a>> MappedOption<'a, T>
Trait Implementations§
Source§impl<'a, T: Debug + MemoryMapped<'a>> Debug for MappedOption<'a, T>
impl<'a, T: Debug + MemoryMapped<'a>> Debug for MappedOption<'a, T>
Source§impl<'a, T: MemoryMapped<'a>> MemoryMapped<'a> for MappedOption<'a, T>
Available on non-target_family=wasm only.
impl<'a, T: MemoryMapped<'a>> MemoryMapped<'a> for MappedOption<'a, T>
Available on non-
target_family=wasm only.Source§impl<'a, T: PartialEq + MemoryMapped<'a>> PartialEq for MappedOption<'a, T>
impl<'a, T: PartialEq + MemoryMapped<'a>> PartialEq for MappedOption<'a, T>
impl<'a, T: Eq + MemoryMapped<'a>> Eq for MappedOption<'a, T>
impl<'a, T: MemoryMapped<'a>> StructuralPartialEq for MappedOption<'a, T>
Auto Trait Implementations§
impl<'a, T> Freeze for MappedOption<'a, T>where
T: Freeze,
impl<'a, T> RefUnwindSafe for MappedOption<'a, T>where
T: RefUnwindSafe,
impl<'a, T> Send for MappedOption<'a, T>where
T: Send,
impl<'a, T> Sync for MappedOption<'a, T>where
T: Sync,
impl<'a, T> Unpin for MappedOption<'a, T>where
T: Unpin,
impl<'a, T> UnwindSafe for MappedOption<'a, T>where
T: UnwindSafe,
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