1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
//! Fill reads: current fills and fill history.
use futures_core::Stream;
use super::{
Fills, PageRequest,
page::{every, history},
};
use crate::{
Result,
model::{Fill, FillHistoryRow, Page},
transport::{Call, ops},
};
impl Fills<'_> {
/// Nonfinal fills plus the latest 50 final ones, newest first: a session's taker and maker
/// fills, or a quoter identity's maker fills. Over 1000 the server answers
/// `SNAPSHOT_TOO_LARGE`: page with [`history`](Self::history).
pub async fn list(&self) -> Result<Vec<Fill>> {
self.inner.send(Call::new(&ops::GET_FILLS), self.auth).await
}
/// One page of fill history, newest first.
pub async fn history(&self, page: &PageRequest) -> Result<Page<FillHistoryRow>> {
history(self.inner, self.auth, &ops::GET_FILL_HISTORY, page).await
}
/// Every fill, newest first, reading pages of `page_size` (clamped to `1..=500`) as
/// consumed. The stream owns what it needs, so it outlives the handle.
pub fn history_stream(
&self,
page_size: u16,
) -> impl Stream<Item = Result<FillHistoryRow>> + Send + Unpin + 'static {
every(self.inner, self.auth, PageRequest::first(page_size), || {
Call::new(&ops::GET_FILL_HISTORY)
})
}
}
#[cfg(test)]
mod tests;