pub struct WatchScanPrimary<'db, 'w> { /* private fields */ }
Expand description
Watch all values.
Implementations§
Source§impl WatchScanPrimary<'_, '_>
impl WatchScanPrimary<'_, '_>
Sourcepub fn all<T: Input>(&self) -> Result<(MpscReceiver<Event>, u64)>
pub fn all<T: Input>(&self) -> Result<(MpscReceiver<Event>, u64)>
Watch all values.
§Example
use native_db::*;
use native_model::{native_model, Model};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[native_model(id=1, version=1)]
#[native_db]
struct Data {
#[primary_key]
id: u64,
}
fn main() -> Result<(), db_type::Error> {
let mut builder = DatabaseBuilder::new();
builder.define::<Data>()?;
let db = builder.create_in_memory()?;
// Open a read transaction
let r = db.r_transaction()?;
// Watch all values
let (_recv, _id) = db.watch().scan().primary().all::<Data>()?;
Ok(())
}
Sourcepub fn range<'a>(
&self,
_range: impl RangeBounds<&'a [u8]> + 'a,
) -> Result<(MpscReceiver<Event>, u64)>
pub fn range<'a>( &self, _range: impl RangeBounds<&'a [u8]> + 'a, ) -> Result<(MpscReceiver<Event>, u64)>
TODO: needs to be implemented
Sourcepub fn start_with<T: Input>(
&self,
start_with: impl InnerKeyValue,
) -> Result<(MpscReceiver<Event>, u64)>
pub fn start_with<T: Input>( &self, start_with: impl InnerKeyValue, ) -> Result<(MpscReceiver<Event>, u64)>
Watch all values starting with the given key.
§Example
use native_db::*;
use native_model::{native_model, Model};
use serde::{Deserialize, Serialize};
#[derive(Serialize, Deserialize)]
#[native_model(id=1, version=1)]
#[native_db]
struct Data {
#[primary_key]
name: String,
}
fn main() -> Result<(), db_type::Error> {
let mut builder = DatabaseBuilder::new();
builder.define::<Data>()?;
let db = builder.create_in_memory()?;
// Open a read transaction
let r = db.r_transaction()?;
// Watch all values starting with "test"
let (_recv, _id) = db.watch().scan().primary().start_with::<Data>("test")?;
Ok(())
}
Auto Trait Implementations§
impl<'db, 'w> Freeze for WatchScanPrimary<'db, 'w>
impl<'db, 'w> RefUnwindSafe for WatchScanPrimary<'db, 'w>
impl<'db, 'w> Send for WatchScanPrimary<'db, 'w>
impl<'db, 'w> Sync for WatchScanPrimary<'db, 'w>
impl<'db, 'w> Unpin for WatchScanPrimary<'db, 'w>
impl<'db, 'w> UnwindSafe for WatchScanPrimary<'db, 'w>
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