experimental module bipack is made pub for test in real projects

This commit is contained in:
Sergey Chernov 2023-10-13 03:28:12 +01:00
parent 89b67f74bc
commit ef42a1b282
4 changed files with 5 additions and 7 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "bipack_ru" name = "bipack_ru"
version = "0.2.1" version = "0.2.2"
edition = "2021" edition = "2021"
license = "Apache-2.0" license = "Apache-2.0"
description = "binary size-effective format used in Divan smart contracts, wasm bindings, network protocols, etc." description = "binary size-effective format used in Divan smart contracts, wasm bindings, network protocols, etc."

View File

@ -15,7 +15,7 @@ The following parts are already safe to use
- u8, u16, u32, u64, `smartint` variable-length unsigned - u8, u16, u32, u64, `smartint` variable-length unsigned
- i8, i16, i32, i64, `smartint` variable-length signed - i8, i16, i32, i64, `smartint` variable-length signed
- strings (utf8, variable length) - strings (utf8, variable length)
- fixed byte arrays - fixed size byte arrays
- variable length byte arrays - variable length byte arrays
The sample code (see `src/lib.rs` for more:) The sample code (see `src/lib.rs` for more:)

View File

@ -133,10 +133,8 @@ pub trait BipackSink {
/// unsigned value except that LSB (bit 0) is used as negative number flag (when set, /// unsigned value except that LSB (bit 0) is used as negative number flag (when set,
/// the encoded number is negative). /// the encoded number is negative).
/// ///
/// Note that because of this the range of supported integers is one bit smaller than /// Note that for really big number using [BipackSink::put_i64] could be more effective
/// i64, only 30 bits for value and one for a sign. This will probably be fixed later /// than the variable-length.
/// but please note that it is impractical to store really big numbers in variable-length
/// format, consider using [BipackSink::put_i64] instead, it has no such limitation.
fn put_signed(self: &mut Self, val: i64) { fn put_signed(self: &mut Self, val: i64) {
let (neg, val) = if val < 0 { (1, -val) } else { (0, val) }; let (neg, val) = if val < 0 { (1, -val) } else { (0, val) };
self.put_unsigned( (neg as u64) | ((val as u64) << 1) ); self.put_unsigned( (neg as u64) | ((val as u64) << 1) );

View File

@ -117,7 +117,7 @@
pub mod bipack_source; pub mod bipack_source;
pub mod bipack_sink; pub mod bipack_sink;
pub mod tools; pub mod tools;
mod bipack; pub mod bipack;
#[cfg(test)] #[cfg(test)]
mod tests { mod tests {