assembly_fdb/ro/
mod.rs

1//! Read-Only low level access to a database file
2
3use std::sync::Arc;
4
5pub use crate::handle::{BaseHandle, Handle, RefHandle};
6
7pub mod buffer;
8pub mod handle;
9pub mod slice;
10
11/// An owned, atomically-reference counted handle to a database
12pub type ArcHandle<B, T> = BaseHandle<Arc<B>, T>;
13
14impl<B: AsRef<[u8]>> ArcHandle<B, ()> {
15    /// Create a new atomically-reference counted handle
16    pub fn new_arc(inner: B) -> Self {
17        Self::new(Arc::new(inner))
18    }
19}
20
21impl<B: AsRef<[u8]>, T: Copy> ArcHandle<B, T> {
22    /// Borrow the atomically-reference counted handle as a byte handle
23    ///
24    /// You can use this function to make cloning cheaper
25    pub fn as_bytes_handle(&self) -> Handle<T> {
26        BaseHandle {
27            mem: self.mem.as_ref().as_ref(),
28            raw: self.raw,
29        }
30    }
31}
32
33/// A handle that contains a slice
34pub type SliceHandle<'a, T> = RefHandle<'a, [T]>;
35
36/// A handle that contains a slice iterator
37pub type SliceIterHandle<'a, T> = Handle<'a, std::slice::Iter<'a, T>>;