pub struct Matrix { /* private fields */ }Implementations§
Source§impl Matrix
Hexadecimal matrix structure
impl Matrix
Hexadecimal matrix structure
§Examples
let arr = "".as_bytes();
let mut m = Matrix::new(20, arr.to_vec());Sourcepub fn new(w: usize, b: Vec<u8>) -> Self
pub fn new(w: usize, b: Vec<u8>) -> Self
Examples found in repository?
examples/main.rs (line 19)
13fn main() {
14 // serialized string
15 println!("-------------------------------- serialized string --------------------------------");
16 let arr = "JOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJEORIJOQWEJREOI
17 QIWJEORIJOQWEJREOIQIJOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJEORIJOQWEJREOI
18 QIWJEORIJOQWEJREOIQIWJEORIJvQIWJQIWJEORIJOQWEJREOIQIWJEORIJvvOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJE ".as_bytes();
19 let mut m = Matrix::new(20, arr.to_vec());
20 m.print_matrix();
21 // serialized struct
22 println!("-------------------------------- serialized struct --------------------------------");
23 let t = Test {
24 a: 1,
25 b: String::from("test"),
26 };
27 let encoded: Vec<u8> = serialize(&t).unwrap();
28 let mut m = Matrix::new(20, encoded.to_vec());
29 m.print_matrix();
30 // serialized file
31 println!("-------------------------------- serialized file --------------------------------");
32 let buffer = fs::read("/resource/TEST_1").expect("read file error");
33 let mut m = Matrix::new(20, buffer.to_vec());
34 m.print_matrix();
35 println!(
36 "-------------------------------- line by line processing --------------------------------"
37 );
38 let lines = m.lines();
39 for (i, v) in lines.iter().enumerate() {
40 println!(
41 "line no:{}, line hex:{}, line info:{}",
42 v.no(),
43 v.hex(),
44 v.info()
45 );
46 }
47}Sourcepub fn print_matrix(&mut self)
pub fn print_matrix(&mut self)
print matrix
§Examples
let arr = "".as_bytes();
let mut m = Matrix::new(20, arr.to_vec());
m.print_matrix();Examples found in repository?
examples/main.rs (line 20)
13fn main() {
14 // serialized string
15 println!("-------------------------------- serialized string --------------------------------");
16 let arr = "JOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJEORIJOQWEJREOI
17 QIWJEORIJOQWEJREOIQIJOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJEORIJOQWEJREOI
18 QIWJEORIJOQWEJREOIQIWJEORIJvQIWJQIWJEORIJOQWEJREOIQIWJEORIJvvOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJE ".as_bytes();
19 let mut m = Matrix::new(20, arr.to_vec());
20 m.print_matrix();
21 // serialized struct
22 println!("-------------------------------- serialized struct --------------------------------");
23 let t = Test {
24 a: 1,
25 b: String::from("test"),
26 };
27 let encoded: Vec<u8> = serialize(&t).unwrap();
28 let mut m = Matrix::new(20, encoded.to_vec());
29 m.print_matrix();
30 // serialized file
31 println!("-------------------------------- serialized file --------------------------------");
32 let buffer = fs::read("/resource/TEST_1").expect("read file error");
33 let mut m = Matrix::new(20, buffer.to_vec());
34 m.print_matrix();
35 println!(
36 "-------------------------------- line by line processing --------------------------------"
37 );
38 let lines = m.lines();
39 for (i, v) in lines.iter().enumerate() {
40 println!(
41 "line no:{}, line hex:{}, line info:{}",
42 v.no(),
43 v.hex(),
44 v.info()
45 );
46 }
47}Sourcepub fn reset(&mut self, b: &[u8])
pub fn reset(&mut self, b: &[u8])
reset matrix
§Examples
let arr = "".as_bytes();
let mut m = Matrix::new(20, arr.to_vec());
let arr2 = "".as_bytes();
m.reset(arr2);Sourcepub fn get_line_by_index(&mut self, index: usize) -> &mut Line
pub fn get_line_by_index(&mut self, index: usize) -> &mut Line
reset matrix
§Examples
let arr = "".as_bytes();
let mut m = Matrix::new(20, arr.to_vec());
let line = m.get_line_by_index(index);Sourcepub fn line_count(&self) -> usize
pub fn line_count(&self) -> usize
reset matrix
§Examples
let arr = "".as_bytes();
let mut m = Matrix::new(20, arr.to_vec());
println("{}", m.line_count());Sourcepub fn lines(&self) -> Vec<Line>
pub fn lines(&self) -> Vec<Line>
get matrix line
§Examples
let arr = "".as_bytes();
let mut m = Matrix::new(20, arr.to_vec());
let lines : Vec<Line> = m.lines();
for (i,v) in lines.iter().enumerate()
{
// ....
}Examples found in repository?
examples/main.rs (line 38)
13fn main() {
14 // serialized string
15 println!("-------------------------------- serialized string --------------------------------");
16 let arr = "JOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJEORIJOQWEJREOI
17 QIWJEORIJOQWEJREOIQIJOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJEORIJOQWEJREOI
18 QIWJEORIJOQWEJREOIQIWJEORIJvQIWJQIWJEORIJOQWEJREOIQIWJEORIJvvOQWEJREOJOQWEJREOIQIWJEORIJOQWEJREOIQIWJE ".as_bytes();
19 let mut m = Matrix::new(20, arr.to_vec());
20 m.print_matrix();
21 // serialized struct
22 println!("-------------------------------- serialized struct --------------------------------");
23 let t = Test {
24 a: 1,
25 b: String::from("test"),
26 };
27 let encoded: Vec<u8> = serialize(&t).unwrap();
28 let mut m = Matrix::new(20, encoded.to_vec());
29 m.print_matrix();
30 // serialized file
31 println!("-------------------------------- serialized file --------------------------------");
32 let buffer = fs::read("/resource/TEST_1").expect("read file error");
33 let mut m = Matrix::new(20, buffer.to_vec());
34 m.print_matrix();
35 println!(
36 "-------------------------------- line by line processing --------------------------------"
37 );
38 let lines = m.lines();
39 for (i, v) in lines.iter().enumerate() {
40 println!(
41 "line no:{}, line hex:{}, line info:{}",
42 v.no(),
43 v.hex(),
44 v.info()
45 );
46 }
47}Auto Trait Implementations§
impl Freeze for Matrix
impl RefUnwindSafe for Matrix
impl Send for Matrix
impl Sync for Matrix
impl Unpin for Matrix
impl UnsafeUnpin for Matrix
impl UnwindSafe for Matrix
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more