pub struct Select<'r, C: Connection, R, T = ()> { /* private fields */ }
Expand description
A select future
Implementations§
Source§impl<C, R, T> Select<'_, C, R, T>where
C: Connection,
impl<C, R, T> Select<'_, C, R, T>where
C: Connection,
Sourcepub fn into_owned(self) -> Select<'static, C, R, T>
pub fn into_owned(self) -> Select<'static, C, R, T>
Converts to an owned type which can easily be moved to a different thread
Source§impl<C> Select<'_, C, Value>where
C: Connection,
impl<C> Select<'_, C, Value>where
C: Connection,
Source§impl<C, R> Select<'_, C, Vec<R>>where
C: Connection,
impl<C, R> Select<'_, C, Vec<R>>where
C: Connection,
Source§impl<'r, C, R> Select<'r, C, R>where
C: Connection,
R: DeserializeOwned,
impl<'r, C, R> Select<'r, C, R>where
C: Connection,
R: DeserializeOwned,
Sourcepub fn live(self) -> Select<'r, C, R, Live>
pub fn live(self) -> Select<'r, C, R, Live>
Turns a normal select query into a live query
§Examples
// Select the namespace/database to use
db.use_ns("namespace").use_db("database").await?;
// Listen to all updates on a table
let mut stream = db.select("person").live().await?;
// Listen to updates on a range of records
let mut stream = db.select("person").range("jane".."john").live().await?;
// Listen to updates on a specific record
let mut stream = db.select(("person", "h5wxrf2ewk8xjxosxtyc")).live().await?;
// The returned stream implements `futures::Stream` so we can
// use it with `futures::StreamExt`, for example.
while let Some(result) = stream.next().await {
handle(result);
}
// Handle the result of the live query notification
fn handle(result: Result<Notification<Person>>) {
match result {
Ok(notification) => println!("{notification:?}"),
Err(error) => eprintln!("{error}"),
}
}
Trait Implementations§
Source§impl<'r, Client, R> IntoFuture for Select<'r, Client, Option<R>>where
Client: Connection,
R: DeserializeOwned,
impl<'r, Client, R> IntoFuture for Select<'r, Client, Option<R>>where
Client: Connection,
R: DeserializeOwned,
Source§type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Option<R>> as IntoFuture>::Output> + Sync + Send + 'r>>
type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Option<R>> as IntoFuture>::Output> + Sync + Send + 'r>>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Source§impl<'r, Client, R> IntoFuture for Select<'r, Client, Option<R>, Live>where
Client: Connection,
R: DeserializeOwned,
impl<'r, Client, R> IntoFuture for Select<'r, Client, Option<R>, Live>where
Client: Connection,
R: DeserializeOwned,
Source§type Output = Result<Stream<Option<R>>, Error>
type Output = Result<Stream<Option<R>>, Error>
The output that the future will produce on completion.
Source§type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Option<R>, Live> as IntoFuture>::Output> + Sync + Send + 'r>>
type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Option<R>, Live> as IntoFuture>::Output> + Sync + Send + 'r>>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Source§impl<'r, Client> IntoFuture for Select<'r, Client, Value>where
Client: Connection,
impl<'r, Client> IntoFuture for Select<'r, Client, Value>where
Client: Connection,
Source§type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Value> as IntoFuture>::Output> + Sync + Send + 'r>>
type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Value> as IntoFuture>::Output> + Sync + Send + 'r>>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Source§impl<'r, Client> IntoFuture for Select<'r, Client, Value, Live>where
Client: Connection,
impl<'r, Client> IntoFuture for Select<'r, Client, Value, Live>where
Client: Connection,
Source§type Output = Result<Stream<Value>, Error>
type Output = Result<Stream<Value>, Error>
The output that the future will produce on completion.
Source§type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Value, Live> as IntoFuture>::Output> + Sync + Send + 'r>>
type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Value, Live> as IntoFuture>::Output> + Sync + Send + 'r>>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Source§impl<'r, Client, R> IntoFuture for Select<'r, Client, Vec<R>>where
Client: Connection,
R: DeserializeOwned,
impl<'r, Client, R> IntoFuture for Select<'r, Client, Vec<R>>where
Client: Connection,
R: DeserializeOwned,
Source§type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Vec<R>> as IntoFuture>::Output> + Sync + Send + 'r>>
type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Vec<R>> as IntoFuture>::Output> + Sync + Send + 'r>>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Source§impl<'r, Client, R> IntoFuture for Select<'r, Client, Vec<R>, Live>where
Client: Connection,
R: DeserializeOwned,
impl<'r, Client, R> IntoFuture for Select<'r, Client, Vec<R>, Live>where
Client: Connection,
R: DeserializeOwned,
Source§type Output = Result<Stream<Vec<R>>, Error>
type Output = Result<Stream<Vec<R>>, Error>
The output that the future will produce on completion.
Source§type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Vec<R>, Live> as IntoFuture>::Output> + Sync + Send + 'r>>
type IntoFuture = Pin<Box<dyn Future<Output = <Select<'r, Client, Vec<R>, Live> as IntoFuture>::Output> + Sync + Send + 'r>>
Which kind of future are we turning this into?
Source§fn into_future(self) -> Self::IntoFuture
fn into_future(self) -> Self::IntoFuture
Creates a future from a value. Read more
Auto Trait Implementations§
impl<'r, C, R, T> Freeze for Select<'r, C, R, T>
impl<'r, C, R, T = ()> !RefUnwindSafe for Select<'r, C, R, T>
impl<'r, C, R, T> Send for Select<'r, C, R, T>
impl<'r, C, R, T> Sync for Select<'r, C, R, T>
impl<'r, C, R, T> Unpin for Select<'r, C, R, T>
impl<'r, C, R, T = ()> !UnwindSafe for Select<'r, C, R, T>
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§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