Skip to content

Commit 9cc988a

Browse files
committed
init commit for toy b64 encoding
0 parents  commit 9cc988a

File tree

4 files changed

+50
-0
lines changed

4 files changed

+50
-0
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/target
2+
/Cargo.lock

Cargo.toml

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
[package]
2+
name = "encode_rs"
3+
version = "0.1.0"
4+
edition = "2021"
5+
6+
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7+
8+
[lib]
9+
name = "encode_rs"
10+
path = "src/lib.rs"
11+
12+
[[bin]]
13+
name = "encode"
14+
path = "src/bin.rs"
15+
16+
[dependencies]
17+
bitvec = "1"
18+
byteorder = "1.4.3"

src/bin.rs

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
use encode_rs::print_bits;
2+
3+
fn main() {
4+
print_bits();
5+
}

src/lib.rs

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
use bitvec::prelude::*;
2+
3+
pub fn print_bits() {
4+
let mut buffer = "hello".as_bytes().to_owned();
5+
// Consume original buffer in u8 to a BitVec buffer
6+
let bits = buffer.view_bits::<Msb0>();
7+
let (head, rest) = bits.split_at(6);
8+
println!("{:?}", bits);
9+
println!("{:?}", head);
10+
println!("{:?}", rest);
11+
// for n in buffer.into_iter() {
12+
// let mut bv: BitVec = n.into();
13+
// bit_buff.append(&mut bv);
14+
// }
15+
}
16+
17+
18+
#[cfg(test)]
19+
mod tests {
20+
#[test]
21+
fn it_works() {
22+
let result = 2 + 2;
23+
assert_eq!(result, 4);
24+
}
25+
}

0 commit comments

Comments
 (0)