Struct Line

Source
pub struct Line { /* private fields */ }

Implementations§

Source§

impl Line

Source

pub fn no(&self) -> &str

Examples found in repository?
examples/main.rs (line 42)
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}
Source

pub fn hex(&self) -> &str

Examples found in repository?
examples/main.rs (line 43)
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}
Source

pub fn info(&self) -> &str

Examples found in repository?
examples/main.rs (line 44)
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}
Source

pub fn push_no(&mut self, no: String)

Source

pub fn push_hex(&mut self, hex: String)

Source

pub fn push_info(&mut self, info: String)

Source

pub fn set_no(&mut self, no: String)

Source

pub fn set_hex(&mut self, hex: String)

Source

pub fn set_info(&mut self, info: String)

Source

pub fn to_string(&self) -> String

Trait Implementations§

Source§

impl Clone for Line

Source§

fn clone(&self) -> Line

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Default for Line

Source§

fn default() -> Line

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl Freeze for Line

§

impl RefUnwindSafe for Line

§

impl Send for Line

§

impl Sync for Line

§

impl Unpin for Line

§

impl UnwindSafe for Line

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.