pub struct ReadRequest {
pub start_seq_num: u64,
pub limit: ReadLimit,
}Expand description
Read request.
Fields§
§start_seq_num: u64Starting sequence number (inclusive).
limit: ReadLimitLimit on how many records can be returned upto a maximum of 1000, or 1MiB of metered bytes.
Implementations§
Source§impl ReadRequest
impl ReadRequest
Sourcepub fn new(start_seq_num: u64) -> Self
pub fn new(start_seq_num: u64) -> Self
Create a new request with start sequence number.
Examples found in repository?
examples/get_latest_record.rs (line 26)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let token = std::env::var("S2_AUTH_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 tail = stream_client.check_tail().await?;
15 if tail == 0 {
16 println!("Empty stream");
17 return Ok(());
18 }
19
20 let latest_seq_num = tail - 1;
21
22 let read_limit = ReadLimit {
23 count: Some(1),
24 bytes: None,
25 };
26 let read_request = ReadRequest::new(latest_seq_num).with_limit(read_limit);
27 let latest_record = stream_client.read(read_request).await?;
28
29 println!("{latest_record:#?}");
30
31 Ok(())
32}Sourcepub fn with_limit(self, limit: ReadLimit) -> Self
pub fn with_limit(self, limit: ReadLimit) -> Self
Overwrite limit.
Examples found in repository?
examples/get_latest_record.rs (line 26)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8 let token = std::env::var("S2_AUTH_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 tail = stream_client.check_tail().await?;
15 if tail == 0 {
16 println!("Empty stream");
17 return Ok(());
18 }
19
20 let latest_seq_num = tail - 1;
21
22 let read_limit = ReadLimit {
23 count: Some(1),
24 bytes: None,
25 };
26 let read_request = ReadRequest::new(latest_seq_num).with_limit(read_limit);
27 let latest_record = stream_client.read(read_request).await?;
28
29 println!("{latest_record:#?}");
30
31 Ok(())
32}Trait Implementations§
Source§impl Clone for ReadRequest
impl Clone for ReadRequest
Source§fn clone(&self) -> ReadRequest
fn clone(&self) -> ReadRequest
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
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
Returns the “default value” for a type. Read more
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
Mutably borrows from an owned value. Read more
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>
Wrap the input message
T in a tonic::Request