Skip to content

Rename fsm feature #69

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 13 additions & 13 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 6 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -23,16 +23,18 @@ self_cell = { version = "1" }
iroh-io = { version = "0.6.2", default-features = false, optional = true }
positioned-io = { version = "0.3.1", default-features = false }
genawaiter = { version = "0.99.1", features = ["futures03"], optional = true }
tokio = { version = "1", features = ["sync"], default-features = false, optional = true }
tokio = { version = "1", features = [
"sync",
], default-features = false, optional = true }
blake3 = { version = "1.8" }
serde = { version = "1", features = ["derive"], optional = true }

[features]
serde = ["dep:serde", "bytes/serde"]
tokio_fsm = ["dep:futures-lite", "dep:iroh-io"]
fsm = ["dep:futures-lite", "dep:iroh-io"]
validate = ["dep:genawaiter"]
experimental-mixed = ["dep:tokio", "dep:serde"]
default = ["tokio_fsm", "validate", "serde"]
default = ["fsm", "validate", "serde"]

[dev-dependencies]
hex = "0.4.3"
Expand Down Expand Up @@ -63,4 +65,4 @@ all-features = true

[[example]]
name = "cli"
required-features = ["tokio_fsm"]
required-features = ["fsm"]
4 changes: 2 additions & 2 deletions src/io/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl From<io::Error> for EncodeError {
}

impl EncodeError {
#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub(crate) fn maybe_parent_write(e: io::Error, node: TreeNode) -> Self {
if e.kind() == io::ErrorKind::ConnectionReset {
Self::ParentWrite(node)
Expand All @@ -170,7 +170,7 @@ impl EncodeError {
}
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub(crate) fn maybe_leaf_write(e: io::Error, chunk: ChunkNum) -> Self {
if e.kind() == io::ErrorKind::ConnectionReset {
Self::LeafWrite(chunk)
Expand Down
2 changes: 1 addition & 1 deletion src/io/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ mod error;
pub use error::*;
use range_collections::{range_set::RangeSetRange, RangeSetRef};

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub mod fsm;
#[cfg(feature = "experimental-mixed")]
pub mod mixed;
Expand Down
12 changes: 6 additions & 6 deletions src/io/outboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ impl crate::io::sync::Outboard for EmptyOutboard {
}
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
impl crate::io::fsm::Outboard for EmptyOutboard {
fn root(&self) -> blake3::Hash {
self.root
Expand Down Expand Up @@ -70,7 +70,7 @@ impl crate::io::sync::OutboardMut for EmptyOutboard {
}
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
impl crate::io::fsm::OutboardMut for EmptyOutboard {
async fn save(
&mut self,
Expand Down Expand Up @@ -242,7 +242,7 @@ impl<T: AsRef<[u8]>> crate::io::sync::Outboard for PostOrderMemOutboard<T> {
}
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
impl<T: AsRef<[u8]>> crate::io::fsm::Outboard for PostOrderMemOutboard<T> {
fn root(&self) -> blake3::Hash {
self.root
Expand Down Expand Up @@ -277,7 +277,7 @@ impl<T: AsMut<[u8]>> crate::io::sync::OutboardMut for PostOrderMemOutboard<T> {
}
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
impl<T: AsMut<[u8]>> crate::io::fsm::OutboardMut for PostOrderMemOutboard<T> {
async fn save(
&mut self,
Expand Down Expand Up @@ -432,7 +432,7 @@ impl<T: AsMut<[u8]>> crate::io::sync::OutboardMut for PreOrderMemOutboard<T> {
}
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
impl<T: AsRef<[u8]>> crate::io::fsm::Outboard for PreOrderMemOutboard<T> {
fn root(&self) -> blake3::Hash {
self.root
Expand All @@ -445,7 +445,7 @@ impl<T: AsRef<[u8]>> crate::io::fsm::Outboard for PreOrderMemOutboard<T> {
}
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
impl<T: AsMut<[u8]>> crate::io::fsm::OutboardMut for PreOrderMemOutboard<T> {
async fn save(
&mut self,
Expand Down
6 changes: 3 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,9 +216,9 @@ pub use tree::{BlockSize, ChunkNum};
pub mod io;
pub use blake3;

#[cfg(all(test, feature = "tokio_fsm"))]
#[cfg(all(test, feature = "fsm"))]
mod tests;
#[cfg(all(test, feature = "tokio_fsm"))]
#[cfg(all(test, feature = "fsm"))]
mod tests2;

/// A set of chunk ranges
Expand Down Expand Up @@ -578,7 +578,7 @@ impl TreeNode {
///
/// This is a bridge from the recursive reference implementation to the node
/// based implementations, and is therefore only used in tests.
#[cfg(all(test, feature = "tokio_fsm"))]
#[cfg(all(test, feature = "fsm"))]
fn from_start_chunk_and_level(start_chunk: ChunkNum, level: BlockSize) -> Self {
let start_chunk = start_chunk.0;
let level = level.0;
Expand Down
16 changes: 8 additions & 8 deletions src/rec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn truncate_ranges(ranges: &ChunkRangesRef, size: u64) -> &ChunkRangesRef {
/// A version of [canonicalize_ranges] that takes and returns an owned [ChunkRanges].
///
/// This is needed for the state machines that own their ranges.
#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub fn truncate_ranges_owned(ranges: crate::ChunkRanges, size: u64) -> crate::ChunkRanges {
let n = truncated_len(&ranges, size);
let mut boundaries = ranges.into_inner();
Expand Down Expand Up @@ -163,7 +163,7 @@ pub(crate) fn encode_selected_rec(

#[cfg(test)]
mod test_support {
#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
use {
crate::{split_inner, TreeNode},
range_collections::{range_set::RangeSetEntry, RangeSet2},
Expand All @@ -188,7 +188,7 @@ mod test_support {
/// within the query range.
///
/// To disable chunk groups entirely, just set both `tree_level` and `min_full_level` to 0.
#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub(crate) fn select_nodes_rec<'a>(
start_chunk: ChunkNum,
size: usize,
Expand Down Expand Up @@ -296,7 +296,7 @@ mod test_support {

/// Reference implementation of the response iterator, using just the simple recursive
/// implementation [select_nodes_rec].
#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub(crate) fn partial_chunk_iter_reference(
tree: BaoTree,
ranges: &ChunkRangesRef,
Expand All @@ -317,7 +317,7 @@ mod test_support {

/// Reference implementation of the response iterator, using just the simple recursive
/// implementation [select_nodes_rec].
#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub(crate) fn response_iter_reference(tree: BaoTree, ranges: &ChunkRangesRef) -> Vec<BaoChunk> {
let mut res = Vec::new();
select_nodes_rec(
Expand Down Expand Up @@ -345,7 +345,7 @@ mod test_support {

impl<'a> ReferencePreOrderPartialChunkIterRef<'a> {
/// Create a new iterator over the tree.
#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub fn new(tree: BaoTree, ranges: &'a ChunkRangesRef, min_full_level: u8) -> Self {
let iter = partial_chunk_iter_reference(tree, ranges, min_full_level).into_iter();
Self { iter, tree }
Expand Down Expand Up @@ -380,7 +380,7 @@ mod test_support {

/// Compute the union of an iterator of ranges. The ranges should be non-overlapping, otherwise
/// the result is None
#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub fn range_union<K: RangeSetEntry>(
ranges: impl IntoIterator<Item = Range<K>>,
) -> Option<RangeSet2<K>> {
Expand All @@ -395,7 +395,7 @@ mod test_support {
Some(res)
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
pub fn get_leaf_ranges<R>(
iter: impl IntoIterator<Item = BaoChunk<R>>,
) -> impl Iterator<Item = Range<u64>> {
Expand Down
2 changes: 1 addition & 1 deletion src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ fn bao_tree_decode_slice_iter_impl(data: Vec<u8>, range: Range<u64>) {
}
}

#[cfg(feature = "tokio_fsm")]
#[cfg(feature = "fsm")]
mod fsm_tests {

use super::*;
Expand Down