Skip to content

Commit c5caa64

Browse files
committed
- Hide the test module from docs (it will be removed/hidden behind a feature flag into a separate crate eventually.
- Make util pub(crate) - Remove unused code in the hash_seq module
1 parent 5ece40f commit c5caa64

File tree

2 files changed

+5
-53
lines changed

2 files changed

+5
-53
lines changed

src/hashseq.rs

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
//! Helpers for blobs that contain a sequence of hashes.
2-
use std::{fmt::Debug, io};
2+
use std::fmt::Debug;
33

44
use bytes::Bytes;
5-
use iroh_io::{AsyncSliceReader, AsyncSliceReaderExt};
65

76
use crate::Hash;
87

@@ -51,34 +50,6 @@ impl IntoIterator for HashSeq {
5150
}
5251
}
5352

54-
/// Stream over the hashes in a [`HashSeq`].
55-
///
56-
/// todo: make this wrap a reader instead of a [`HashSeq`].
57-
#[derive(Debug, Clone)]
58-
pub struct HashSeqStream(HashSeq);
59-
60-
impl HashSeqStream {
61-
/// Get the next hash in the sequence.
62-
#[allow(clippy::should_implement_trait, clippy::unused_async)]
63-
pub async fn next(&mut self) -> io::Result<Option<Hash>> {
64-
Ok(self.0.pop_front())
65-
}
66-
67-
/// Skip a number of hashes in the sequence.
68-
#[allow(clippy::unused_async)]
69-
pub async fn skip(&mut self, n: u64) -> io::Result<()> {
70-
let ok = self.0.drop_front(n as usize);
71-
if !ok {
72-
Err(io::Error::new(
73-
io::ErrorKind::UnexpectedEof,
74-
"end of sequence",
75-
))
76-
} else {
77-
Ok(())
78-
}
79-
}
80-
}
81-
8253
impl HashSeq {
8354
/// Create a new sequence of hashes.
8455
pub fn new(bytes: Bytes) -> Option<Self> {
@@ -89,16 +60,6 @@ impl HashSeq {
8960
}
9061
}
9162

92-
fn drop_front(&mut self, n: usize) -> bool {
93-
let start = n * 32;
94-
if start > self.0.len() {
95-
false
96-
} else {
97-
self.0 = self.0.slice(start..);
98-
true
99-
}
100-
}
101-
10263
/// Iterate over the hashes in this sequence.
10364
pub fn iter(&self) -> impl Iterator<Item = Hash> + '_ {
10465
self.0.chunks_exact(32).map(|chunk| {
@@ -155,14 +116,3 @@ impl Iterator for HashSeqIter {
155116
self.0.pop_front()
156117
}
157118
}
158-
159-
/// Parse a sequence of hashes.
160-
pub async fn parse_hash_seq<'a, R: AsyncSliceReader + 'a>(
161-
mut reader: R,
162-
) -> anyhow::Result<(HashSeqStream, u64)> {
163-
let bytes = reader.read_to_end().await?;
164-
let hashes = HashSeq::try_from(bytes)?;
165-
let num_hashes = hashes.len() as u64;
166-
let stream = HashSeqStream(hashes);
167-
Ok((stream, num_hashes))
168-
}

src/lib.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,11 @@ mod net_protocol;
1111
pub use net_protocol::BlobsProtocol;
1212
pub mod protocol;
1313
pub mod provider;
14-
pub mod test;
1514
pub mod ticket;
16-
pub mod util;
15+
16+
#[doc(hidden)]
17+
pub mod test;
18+
mod util;
1719

1820
#[cfg(test)]
1921
mod tests;

0 commit comments

Comments
 (0)