-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from earthstar-project/relative-encodings
Relative encodings
- Loading branch information
Showing
62 changed files
with
3,008 additions
and
382 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,5 @@ | |
members = ["data-model", "earthstar", "fuzz"] | ||
resolver = "2" | ||
|
||
[workspace.lints.clippy] | ||
type_complexity = "allow" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
use either::Either; | ||
use ufotofu::local_nb::BulkProducer; | ||
|
||
use crate::encoding::error::DecodeError; | ||
|
||
/// Have `Producer` produce a single byte, or return an error if the final value was produced or the producer experienced an error. | ||
pub async fn produce_byte<Producer>( | ||
producer: &mut Producer, | ||
) -> Result<u8, DecodeError<Producer::Error>> | ||
where | ||
Producer: BulkProducer<Item = u8>, | ||
{ | ||
match producer.produce().await { | ||
Ok(Either::Left(item)) => Ok(item), | ||
Ok(Either::Right(_)) => Err(DecodeError::InvalidInput), | ||
Err(err) => Err(DecodeError::Producer(err)), | ||
} | ||
} | ||
|
||
pub fn is_bitflagged(byte: u8, position: u8) -> bool { | ||
let mask = match position { | ||
0 => 0b1000_0000, | ||
1 => 0b0100_0000, | ||
2 => 0b0010_0000, | ||
3 => 0b0001_0000, | ||
4 => 0b0000_1000, | ||
5 => 0b0000_0100, | ||
6 => 0b0000_0010, | ||
7 => 0b0000_0001, | ||
_ => panic!("Can't check for a bitflag at a position greater than 7"), | ||
}; | ||
|
||
byte & mask == mask | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
pub mod bytes; | ||
pub mod compact_width; | ||
pub mod error; | ||
pub mod max_power; | ||
pub mod parameters; | ||
pub mod relativity; | ||
pub(crate) mod shared_buffers; | ||
pub mod unsigned_int; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.