diff --git a/iroh/src/client.rs b/iroh/src/client.rs index 1b8bf75b0a..66eb926a26 100644 --- a/iroh/src/client.rs +++ b/iroh/src/client.rs @@ -26,13 +26,17 @@ mod node; #[derive(Debug, Clone)] pub struct Iroh { /// Client for blobs operations. - blobs: blobs::Client, + #[deprecated(note = "Use `blobs` method instead", since = "0.18.0")] + pub blobs: blobs::Client, /// Client for docs operations. - docs: docs::Client, + #[deprecated(note = "Use `docs` method instead", since = "0.18.0")] + pub docs: docs::Client, /// Client for author operations. - authors: authors::Client, + #[deprecated(note = "Use `authors` method instead", since = "0.18.0")] + pub authors: authors::Client, /// Client for tags operations. - tags: tags::Client, + #[deprecated(note = "Use `tags` method instead", since = "0.18.0")] + pub tags: tags::Client, rpc: RpcClient, } @@ -43,6 +47,7 @@ where { /// Create a new high-level client to a Iroh node from the low-level RPC client. pub fn new(rpc: RpcClient) -> Self { + #[allow(deprecated)] Self { blobs: blobs::Client { rpc: rpc.clone() }, docs: docs::Client { rpc: rpc.clone() }, @@ -52,23 +57,27 @@ where } } - /// + /// Client for blobs operations. pub fn blobs(&self) -> &blobs::Client { + #[allow(deprecated)] &self.blobs } - /// + /// Client for docs operations. pub fn docs(&self) -> &docs::Client { + #[allow(deprecated)] &self.docs } - /// + /// Client for author operations. pub fn authors(&self) -> &authors::Client { + #[allow(deprecated)] &self.authors } - /// + /// Client for tags operations. pub fn tags(&self) -> &tags::Client { + #[allow(deprecated)] &self.tags } } diff --git a/iroh/src/client/authors.rs b/iroh/src/client/authors.rs index b695b3da7c..e6bddbb494 100644 --- a/iroh/src/client/authors.rs +++ b/iroh/src/client/authors.rs @@ -101,33 +101,33 @@ mod tests { let node = Node::memory().spawn().await?; // default author always exists - let authors: Vec<_> = node.authors.list().await?.try_collect().await?; + let authors: Vec<_> = node.authors().list().await?.try_collect().await?; assert_eq!(authors.len(), 1); - let default_author = node.authors.default().await?; + let default_author = node.authors().default().await?; assert_eq!(authors, vec![default_author]); - let author_id = node.authors.create().await?; + let author_id = node.authors().create().await?; - let authors: Vec<_> = node.authors.list().await?.try_collect().await?; + let authors: Vec<_> = node.authors().list().await?.try_collect().await?; assert_eq!(authors.len(), 2); let author = node - .authors + .authors() .export(author_id) .await? .expect("should have author"); - node.authors.delete(author_id).await?; - let authors: Vec<_> = node.authors.list().await?.try_collect().await?; + node.authors().delete(author_id).await?; + let authors: Vec<_> = node.authors().list().await?.try_collect().await?; assert_eq!(authors.len(), 1); - node.authors.import(author).await?; + node.authors().import(author).await?; - let authors: Vec<_> = node.authors.list().await?.try_collect().await?; + let authors: Vec<_> = node.authors().list().await?.try_collect().await?; assert_eq!(authors.len(), 2); - assert!(node.authors.default().await? != author_id); - node.authors.set_default(author_id).await?; - assert_eq!(node.authors.default().await?, author_id); + assert!(node.authors().default().await? != author_id); + node.authors().set_default(author_id).await?; + assert_eq!(node.authors().default().await?, author_id); Ok(()) } diff --git a/iroh/src/client/blobs.rs b/iroh/src/client/blobs.rs index 78b3bc94fa..b887edf9fe 100644 --- a/iroh/src/client/blobs.rs +++ b/iroh/src/client/blobs.rs @@ -936,7 +936,7 @@ mod tests { // import files for path in &paths { let import_outcome = client - .blobs + .blobs() .add_from_path( path.to_path_buf(), false, @@ -957,7 +957,7 @@ mod tests { } let (hash, tag) = client - .blobs + .blobs() .create_collection(collection, SetTagOption::Auto, tags) .await?; @@ -978,7 +978,7 @@ mod tests { } // check that "temp" tags have been deleted - let tags: Vec<_> = client.tags.list().await?.try_collect().await?; + let tags: Vec<_> = client.tags().list().await?.try_collect().await?; assert_eq!(tags.len(), 1); assert_eq!(tags[0].hash, hash); assert_eq!(tags[0].name, tag); @@ -1013,7 +1013,7 @@ mod tests { let client = node.client(); let import_outcome = client - .blobs + .blobs() .add_from_path( path.to_path_buf(), false, @@ -1043,14 +1043,14 @@ mod tests { // Read at equal to blob_get_chunk_size let res = client - .blobs + .blobs() .read_at_to_bytes(hash, 0, Some(1024 * 64)) .await?; assert_eq!(res.len(), 1024 * 64); assert_eq!(&res[..], &buf[0..1024 * 64]); let res = client - .blobs + .blobs() .read_at_to_bytes(hash, 20, Some(1024 * 64)) .await?; assert_eq!(res.len(), 1024 * 64); @@ -1058,14 +1058,14 @@ mod tests { // Read at larger than blob_get_chunk_size let res = client - .blobs + .blobs() .read_at_to_bytes(hash, 0, Some(10 + 1024 * 64)) .await?; assert_eq!(res.len(), 10 + 1024 * 64); assert_eq!(&res[..], &buf[0..(10 + 1024 * 64)]); let res = client - .blobs + .blobs() .read_at_to_bytes(hash, 20, Some(10 + 1024 * 64)) .await?; assert_eq!(res.len(), 10 + 1024 * 64); @@ -1119,7 +1119,7 @@ mod tests { // import files for path in &paths { let import_outcome = client - .blobs + .blobs() .add_from_path( path.to_path_buf(), false, @@ -1140,7 +1140,7 @@ mod tests { } let (hash, _tag) = client - .blobs + .blobs() .create_collection(collection, SetTagOption::Auto, tags) .await?; @@ -1178,7 +1178,7 @@ mod tests { let client = node.client(); let import_outcome = client - .blobs + .blobs() .add_from_path( path.to_path_buf(), false, @@ -1192,7 +1192,7 @@ mod tests { .context("import finish")?; let ticket = client - .blobs + .blobs() .share(import_outcome.hash, BlobFormat::Raw, Default::default()) .await?; assert_eq!(ticket.hash(), import_outcome.hash);