add doc comment examples for whoami api

This commit is contained in:
glyph 2022-02-14 16:41:00 +02:00
parent 1bb9e1f7e1
commit 32bd924e7e
1 changed files with 17 additions and 1 deletions

View File

@ -7,7 +7,23 @@
use crate::{error::GolgiError, sbot::Sbot, utils};
impl Sbot {
/// Call the `whoami` RPC method and return an `id`.
/// Get the public key of the local identity.
///
/// # Example
///
/// ```rust
/// use golgi::{Sbot, GolgiError};
///
/// async fn fetch_id() -> Result<(), GolgiError> {
/// let mut sbot_client = Sbot::init(None, None).await?;
///
/// let pub_key = sbot_client.whoami().await?;
///
/// println!("local ssb id: {}", pub_key);
///
/// Ok(())
/// }
/// ```
pub async fn whoami(&mut self) -> Result<String, GolgiError> {
let mut sbot_connection = self.get_sbot_connection().await?;
let req_id = sbot_connection.client.whoami_req_send().await?;