add doc comment examples for history api

This commit is contained in:
glyph 2022-02-14 16:13:19 +02:00
parent 29d1927104
commit b714bda988
1 changed files with 32 additions and 2 deletions

View File

@ -10,8 +10,38 @@ use kuska_ssb::api::dto::CreateHistoryStreamIn;
use crate::{error::GolgiError, messages::SsbMessageValue, sbot::Sbot, utils};
impl Sbot {
/// Call the `createHistoryStream` RPC method
/// and return a Stream of Result<SsbMessageValue, GolgiError>.
/// Call the `createHistoryStream` RPC method.
///
/// # Example
///
/// ```rust
/// use async_std::stream::StreamExt;
/// use golgi::{
/// Sbot,
/// GolgiError,
/// api::get_subset::{
/// SubsetQuery,
/// SubsetQueryOptions
/// }
/// };
///
/// async fn history() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?;
///
/// let ssb_id = "@zqshk7o2Rpd/OaZ/MxH6xXONgonP1jH+edK9+GZb/NY=.ed25519".to_string();
///
/// let history_stream = sbot_client.create_history_stream(ssb_id).await?;
///
/// history_stream.for_each(|msg| {
/// match msg {
/// Ok(val) => println!("msg value: {:?}", val),
/// Err(e) => eprintln!("error: {}", e),
/// }
/// }).await;
///
/// Ok(())
/// }
/// ```
pub async fn create_history_stream(
&mut self,
id: String,