pub struct ReadRequest {
pub start: ReadStart,
pub limit: ReadLimit,
pub until: Option<RangeTo<u64>>,
pub clamp: bool,
}
Expand description
Read request.
Fields§
§start: ReadStart
Starting position for records. Retrieved batches will start at the first record whose position is greater than or equal to it.
limit: ReadLimit
Limit how many records can be returned. This will get capped at the default limit, which is up to 1000 records or 1MiB of metered bytes.
until: Option<RangeTo<u64>>
Exclusive timestamp to read until.
If provided, this is applied as an additional constraint on top of the limit
,
and will guarantee that all records returned have timestamps < the provided until
.
clamp: bool
Clamp the start position at the tail position. If set, the read will start at the tail of the stream if the requested position is greater than it.
Implementations§
Source§impl ReadRequest
impl ReadRequest
Sourcepub fn new(start: ReadStart) -> Self
pub fn new(start: ReadStart) -> Self
Create a new request with the specified starting point.
Examples found in repository?
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let token = std::env::var("S2_ACCESS_TOKEN")?;
9 let config = ClientConfig::new(token);
10 let basin: BasinName = "my-favorite-basin".parse()?;
11 let stream = "my-favorite-stream";
12 let stream_client = StreamClient::new(config, basin, stream);
13
14 let read_limit = ReadLimit::new().with_count(1);
15 let read_request = ReadRequest::new(ReadStart::TailOffset(1)).with_limit(read_limit);
16 let latest_record = stream_client.read(read_request).await?;
17
18 println!("{latest_record:#?}");
19
20 Ok(())
21}
Sourcepub fn with_limit(self, limit: ReadLimit) -> Self
pub fn with_limit(self, limit: ReadLimit) -> Self
Overwrite limit.
Examples found in repository?
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let token = std::env::var("S2_ACCESS_TOKEN")?;
9 let config = ClientConfig::new(token);
10 let basin: BasinName = "my-favorite-basin".parse()?;
11 let stream = "my-favorite-stream";
12 let stream_client = StreamClient::new(config, basin, stream);
13
14 let read_limit = ReadLimit::new().with_count(1);
15 let read_request = ReadRequest::new(ReadStart::TailOffset(1)).with_limit(read_limit);
16 let latest_record = stream_client.read(read_request).await?;
17
18 println!("{latest_record:#?}");
19
20 Ok(())
21}
Sourcepub fn with_until(self, until: RangeTo<u64>) -> Self
pub fn with_until(self, until: RangeTo<u64>) -> Self
Provide an until
timestamp.
Sourcepub fn with_clamp(self, clamp: bool) -> Self
pub fn with_clamp(self, clamp: bool) -> Self
Clamp the start position at the tail position.
Trait Implementations§
Source§impl Clone for ReadRequest
impl Clone for ReadRequest
Source§fn clone(&self) -> ReadRequest
fn clone(&self) -> ReadRequest
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for ReadRequest
impl Debug for ReadRequest
Source§impl Default for ReadRequest
impl Default for ReadRequest
Source§fn default() -> ReadRequest
fn default() -> ReadRequest
Auto Trait Implementations§
impl Freeze for ReadRequest
impl RefUnwindSafe for ReadRequest
impl Send for ReadRequest
impl Sync for ReadRequest
impl Unpin for ReadRequest
impl UnwindSafe for ReadRequest
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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>
T
in a tonic::Request