Skip to content

Commit

Permalink
docs(autonomi): add archive_get rustdoc example
Browse files Browse the repository at this point in the history
  • Loading branch information
b-zee committed Dec 4, 2024
1 parent ef3a2b1 commit 90b15fb
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions autonomi/src/client/archive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,19 @@ impl Archive {

impl Client {
/// Fetch an archive from the network
///
/// # Example
///
/// ```no_run
/// # use autonomi::client::{Client, archive::ArchiveAddr};
/// # #[tokio::main]
/// # async fn main() -> Result<(), Box<dyn std::error::Error>> {
/// # let peers = ["/ip4/127.0.0.1/udp/1234/quic-v1".parse()?];
/// let client = Client::connect(&peers).await?;
/// let archive = client.archive_get(ArchiveAddr::random(&mut rand::thread_rng())).await?;
/// # Ok(())
/// # }
/// ```
pub async fn archive_get(&self, addr: ArchiveAddr) -> Result<Archive, GetError> {
let data = self.data_get(addr).await?;
Ok(Archive::from_bytes(data)?)
Expand Down

0 comments on commit 90b15fb

Please sign in to comment.