pub struct EventQueryBuilder { /* private fields */ }Expand description
Builder for constructing event queries with options.
§Example
ⓘ
// Get all events as a stream
let events = db.events(EventSelector::all()).stream();
// Get first 10 events in reverse order, collected to a Vec
let events: Vec<Event> = db
.events(EventSelector::stream_equals("my-stream"))
.reverse()
.limit(10)
.collect()
.await;
// Get just the first event
let first = db.events(EventSelector::all()).first().await;Implementations§
Source§impl EventQueryBuilder
impl EventQueryBuilder
Sourcepub fn new(database: DatabaseAtRevisionImpl, selector: EventSelector) -> Self
pub fn new(database: DatabaseAtRevisionImpl, selector: EventSelector) -> Self
Create a new event query builder.
Sourcepub fn direction(self, direction: QueryDirection) -> Self
pub fn direction(self, direction: QueryDirection) -> Self
Set the query direction.
Sourcepub async fn first(self) -> Option<Event>
pub async fn first(self) -> Option<Event>
Execute the query and return just the first event, if any.
Sourcepub fn typed<T>(self) -> TypedEventQuery<T>
pub fn typed<T>(self) -> TypedEventQuery<T>
Create a typed event query that filters and converts events.
The type T must implement TryFrom<&Event>. Events that fail to
convert are silently skipped.
§Example
ⓘ
#[derive(Debug)]
struct AccountCreated { name: String }
impl TryFrom<&Event> for AccountCreated {
type Error = Box<dyn std::error::Error>;
fn try_from(event: &Event) -> Result<Self, Self::Error> {
// Parse the event data...
}
}
let accounts: Vec<AccountCreated> = db
.events(EventSelector::type_equals("AccountCreated"))
.typed::<AccountCreated>()
.collect()
.await;Auto Trait Implementations§
impl Freeze for EventQueryBuilder
impl !RefUnwindSafe for EventQueryBuilder
impl Send for EventQueryBuilder
impl Sync for EventQueryBuilder
impl Unpin for EventQueryBuilder
impl !UnwindSafe for EventQueryBuilder
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> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request