38 lines
1.3 KiB
Rust
38 lines
1.3 KiB
Rust
use async_std::stream::Stream;
|
|
|
|
use crate::{
|
|
error::GolgiError, messages::SsbMessageValue, sbot::sbot_connection::Sbot, utils,
|
|
utils::get_source_stream,
|
|
};
|
|
|
|
pub use kuska_ssb::api::dto::content::{SubsetQuery, SubsetQueryOptions};
|
|
|
|
impl Sbot {
|
|
/// Call the `partialReplication getSubset` RPC method
|
|
/// and return a Stream of Result<SsbMessageValue, GolgiError>
|
|
///
|
|
/// # Arguments
|
|
///
|
|
/// * `query` - A `SubsetQuery` which specifies what filters to use.
|
|
/// * `option` - An Option<`SubsetQueryOptions`> which, if provided, adds additional
|
|
/// specifications to the query, such as specifying page limit and/or descending.
|
|
pub async fn get_subset_stream(
|
|
&mut self,
|
|
query: SubsetQuery,
|
|
options: Option<SubsetQueryOptions>,
|
|
) -> Result<impl Stream<Item = Result<SsbMessageValue, GolgiError>>, GolgiError> {
|
|
let mut sbot_connection = self.get_sbot_connection().await?;
|
|
let req_id = sbot_connection
|
|
.client
|
|
.getsubset_req_send(query, options)
|
|
.await?;
|
|
let get_subset_stream = get_source_stream(
|
|
sbot_connection.rpc_reader,
|
|
req_id,
|
|
utils::ssb_message_res_parse,
|
|
)
|
|
.await;
|
|
Ok(get_subset_stream)
|
|
}
|
|
}
|