pub struct RedbStore {
db: Arc<Database>,
_tmp: Option<NamedTempFile>,
}Expand description
Implementation of OutgoingIndexStore and TicketQueueStore using redb database and postcard serializer.
The store is intentionally not cloneable to allow the owner to have complete ownership of the database.
Fields§
§db: Arc<Database>§_tmp: Option<NamedTempFile>Implementations§
Source§impl RedbStore
impl RedbStore
Sourcepub fn new(path: impl AsRef<Path>) -> Result<Self, RedbStoreError>
pub fn new(path: impl AsRef<Path>) -> Result<Self, RedbStoreError>
Creates a new instance on the given path.
Sourcepub fn new_temp() -> Result<Self, RedbStoreError>
pub fn new_temp() -> Result<Self, RedbStoreError>
Creates a new instance using a temporary file.
The temporary file is automatically deleted when the store is dropped.
Trait Implementations§
Source§impl OutgoingIndexStore for RedbStore
impl OutgoingIndexStore for RedbStore
type Error = RedbStoreError
Source§fn load_outgoing_index(
&self,
channel_id: &ChannelId,
epoch: u32,
) -> Result<Option<u64>, Self::Error>
fn load_outgoing_index( &self, channel_id: &ChannelId, epoch: u32, ) -> Result<Option<u64>, Self::Error>
Loads the last used outgoing ticket index for the given channel and epoch. Read more
Source§fn save_outgoing_index(
&mut self,
channel_id: &ChannelId,
epoch: u32,
index: u64,
) -> Result<(), Self::Error>
fn save_outgoing_index( &mut self, channel_id: &ChannelId, epoch: u32, index: u64, ) -> Result<(), Self::Error>
Saves the last used outgoing ticket index for the given channel and epoch.
Source§impl TicketQueueStore for RedbStore
impl TicketQueueStore for RedbStore
Source§type Queue = RedbTicketQueue
type Queue = RedbTicketQueue
Type of per-channel incoming ticket queues.
Source§fn open_or_create_queue(
&mut self,
channel_id: &ChannelId,
) -> Result<Self::Queue, <Self::Queue as TicketQueue>::Error>
fn open_or_create_queue( &mut self, channel_id: &ChannelId, ) -> Result<Self::Queue, <Self::Queue as TicketQueue>::Error>
Opens or creates a new queue in storage for the given channel.
Source§fn delete_queue(
&mut self,
channel_id: &ChannelId,
) -> Result<Vec<VerifiedTicket>, <Self::Queue as TicketQueue>::Error>
fn delete_queue( &mut self, channel_id: &ChannelId, ) -> Result<Vec<VerifiedTicket>, <Self::Queue as TicketQueue>::Error>
Deletes the queue for the given channel. Read more
Source§fn iter_queues(
&self,
) -> Result<impl Iterator<Item = ChannelId>, <Self::Queue as TicketQueue>::Error>
fn iter_queues( &self, ) -> Result<impl Iterator<Item = ChannelId>, <Self::Queue as TicketQueue>::Error>
Iterate over all channel IDs of ticket queues in the storage.
Auto Trait Implementations§
impl Freeze for RedbStore
impl !RefUnwindSafe for RedbStore
impl Send for RedbStore
impl Sync for RedbStore
impl Unpin for RedbStore
impl !UnwindSafe for RedbStore
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more