Struct LDWriter

Source
pub struct LDWriter<'a, S: Write + Seek> { /* private fields */ }

Implementations§

Source§

impl<'a, S: Write + Seek> LDWriter<'a, S>

Source

pub fn new(sink: &'a mut S, header: Header) -> Self

Examples found in repository?
examples/write.rs (line 95)
4fn main() -> I2Result<()> {
5    let filename = "test_write.ld";
6    println!("Writing file: {}", filename);
7
8    let mut file = File::create(filename).expect("Failed to open file!");
9
10    let header = Header {
11        channel_meta_ptr: 13384,
12        channel_data_ptr: 23056,
13        event_ptr: 1762,
14        device_serial: 12007,
15        device_type: "ADL".to_string(),
16        device_version: 420,
17        num_channels: 1,
18        date_string: "23/11/2005".to_string(),
19        time_string: "09:53:00".to_string(),
20        driver: "".to_string(),
21        vehicleid: "11A".to_string(),
22        venue: "Calder".to_string(),
23        session: "2".to_string(),
24        short_comment: "second warmup".to_string(),
25    };
26
27    let channel0_meta = ChannelMetadata {
28        prev_addr: 0,
29        next_addr: 0,
30        data_addr: 0,
31        data_count: 0,
32        datatype: Datatype::I16,
33        sample_rate: 2,
34        offset: 0,
35        mul: 1,
36        scale: 1,
37        dec_places: 1,
38        name: "Air Temp Inlet".to_string(),
39        short_name: "Air Tem".to_string(),
40        unit: "C".to_string(),
41    };
42    let channel0_samples = vec![
43        Sample::I16(190),
44        Sample::I16(190),
45        Sample::I16(190),
46        Sample::I16(190),
47        Sample::I16(200),
48        Sample::I16(200),
49        Sample::I16(200),
50        Sample::I16(200),
51        Sample::I16(200),
52        Sample::I16(200),
53        Sample::I16(200),
54        Sample::I16(200),
55        Sample::I16(200),
56        Sample::I16(190),
57        Sample::I16(190),
58        Sample::I16(190),
59    ];
60
61    let gps_lat_meta = ChannelMetadata {
62        prev_addr: 0,
63        next_addr: 0,
64        data_addr: 0,
65        data_count: 0,
66        datatype: Datatype::I32,
67        sample_rate: 2,
68        offset: 0,
69        mul: 1,
70        scale: 1,
71        dec_places: 7,
72        name: "GPS Latitude".to_string(),
73        short_name: "GPS Lat".to_string(),
74        unit: "deg".to_string(),
75    };
76    let gps_lat_samples = vec![
77        Sample::I32(387867788),
78        Sample::I32(387867788),
79        Sample::I32(387867788),
80        Sample::I32(387867788),
81        Sample::I32(387867788),
82        Sample::I32(387867788),
83        Sample::I32(387867788),
84        Sample::I32(387867788),
85        Sample::I32(387867777),
86        Sample::I32(387867788),
87        Sample::I32(387867788),
88        Sample::I32(387867788),
89        Sample::I32(387867788),
90        Sample::I32(387867788),
91        Sample::I32(387867788),
92        Sample::I32(387867788),
93    ];
94
95    LDWriter::new(&mut file, header)
96        .with_channel(channel0_meta, channel0_samples)
97        .with_channel(gps_lat_meta, gps_lat_samples)
98        .write()?;
99
100    Ok(())
101}
Source

pub fn with_channel(self, channel: ChannelMetadata, data: Vec<Sample>) -> Self

Examples found in repository?
examples/write.rs (line 96)
4fn main() -> I2Result<()> {
5    let filename = "test_write.ld";
6    println!("Writing file: {}", filename);
7
8    let mut file = File::create(filename).expect("Failed to open file!");
9
10    let header = Header {
11        channel_meta_ptr: 13384,
12        channel_data_ptr: 23056,
13        event_ptr: 1762,
14        device_serial: 12007,
15        device_type: "ADL".to_string(),
16        device_version: 420,
17        num_channels: 1,
18        date_string: "23/11/2005".to_string(),
19        time_string: "09:53:00".to_string(),
20        driver: "".to_string(),
21        vehicleid: "11A".to_string(),
22        venue: "Calder".to_string(),
23        session: "2".to_string(),
24        short_comment: "second warmup".to_string(),
25    };
26
27    let channel0_meta = ChannelMetadata {
28        prev_addr: 0,
29        next_addr: 0,
30        data_addr: 0,
31        data_count: 0,
32        datatype: Datatype::I16,
33        sample_rate: 2,
34        offset: 0,
35        mul: 1,
36        scale: 1,
37        dec_places: 1,
38        name: "Air Temp Inlet".to_string(),
39        short_name: "Air Tem".to_string(),
40        unit: "C".to_string(),
41    };
42    let channel0_samples = vec![
43        Sample::I16(190),
44        Sample::I16(190),
45        Sample::I16(190),
46        Sample::I16(190),
47        Sample::I16(200),
48        Sample::I16(200),
49        Sample::I16(200),
50        Sample::I16(200),
51        Sample::I16(200),
52        Sample::I16(200),
53        Sample::I16(200),
54        Sample::I16(200),
55        Sample::I16(200),
56        Sample::I16(190),
57        Sample::I16(190),
58        Sample::I16(190),
59    ];
60
61    let gps_lat_meta = ChannelMetadata {
62        prev_addr: 0,
63        next_addr: 0,
64        data_addr: 0,
65        data_count: 0,
66        datatype: Datatype::I32,
67        sample_rate: 2,
68        offset: 0,
69        mul: 1,
70        scale: 1,
71        dec_places: 7,
72        name: "GPS Latitude".to_string(),
73        short_name: "GPS Lat".to_string(),
74        unit: "deg".to_string(),
75    };
76    let gps_lat_samples = vec![
77        Sample::I32(387867788),
78        Sample::I32(387867788),
79        Sample::I32(387867788),
80        Sample::I32(387867788),
81        Sample::I32(387867788),
82        Sample::I32(387867788),
83        Sample::I32(387867788),
84        Sample::I32(387867788),
85        Sample::I32(387867777),
86        Sample::I32(387867788),
87        Sample::I32(387867788),
88        Sample::I32(387867788),
89        Sample::I32(387867788),
90        Sample::I32(387867788),
91        Sample::I32(387867788),
92        Sample::I32(387867788),
93    ];
94
95    LDWriter::new(&mut file, header)
96        .with_channel(channel0_meta, channel0_samples)
97        .with_channel(gps_lat_meta, gps_lat_samples)
98        .write()?;
99
100    Ok(())
101}
Source

pub fn write(self) -> I2Result<()>

Examples found in repository?
examples/write.rs (line 98)
4fn main() -> I2Result<()> {
5    let filename = "test_write.ld";
6    println!("Writing file: {}", filename);
7
8    let mut file = File::create(filename).expect("Failed to open file!");
9
10    let header = Header {
11        channel_meta_ptr: 13384,
12        channel_data_ptr: 23056,
13        event_ptr: 1762,
14        device_serial: 12007,
15        device_type: "ADL".to_string(),
16        device_version: 420,
17        num_channels: 1,
18        date_string: "23/11/2005".to_string(),
19        time_string: "09:53:00".to_string(),
20        driver: "".to_string(),
21        vehicleid: "11A".to_string(),
22        venue: "Calder".to_string(),
23        session: "2".to_string(),
24        short_comment: "second warmup".to_string(),
25    };
26
27    let channel0_meta = ChannelMetadata {
28        prev_addr: 0,
29        next_addr: 0,
30        data_addr: 0,
31        data_count: 0,
32        datatype: Datatype::I16,
33        sample_rate: 2,
34        offset: 0,
35        mul: 1,
36        scale: 1,
37        dec_places: 1,
38        name: "Air Temp Inlet".to_string(),
39        short_name: "Air Tem".to_string(),
40        unit: "C".to_string(),
41    };
42    let channel0_samples = vec![
43        Sample::I16(190),
44        Sample::I16(190),
45        Sample::I16(190),
46        Sample::I16(190),
47        Sample::I16(200),
48        Sample::I16(200),
49        Sample::I16(200),
50        Sample::I16(200),
51        Sample::I16(200),
52        Sample::I16(200),
53        Sample::I16(200),
54        Sample::I16(200),
55        Sample::I16(200),
56        Sample::I16(190),
57        Sample::I16(190),
58        Sample::I16(190),
59    ];
60
61    let gps_lat_meta = ChannelMetadata {
62        prev_addr: 0,
63        next_addr: 0,
64        data_addr: 0,
65        data_count: 0,
66        datatype: Datatype::I32,
67        sample_rate: 2,
68        offset: 0,
69        mul: 1,
70        scale: 1,
71        dec_places: 7,
72        name: "GPS Latitude".to_string(),
73        short_name: "GPS Lat".to_string(),
74        unit: "deg".to_string(),
75    };
76    let gps_lat_samples = vec![
77        Sample::I32(387867788),
78        Sample::I32(387867788),
79        Sample::I32(387867788),
80        Sample::I32(387867788),
81        Sample::I32(387867788),
82        Sample::I32(387867788),
83        Sample::I32(387867788),
84        Sample::I32(387867788),
85        Sample::I32(387867777),
86        Sample::I32(387867788),
87        Sample::I32(387867788),
88        Sample::I32(387867788),
89        Sample::I32(387867788),
90        Sample::I32(387867788),
91        Sample::I32(387867788),
92        Sample::I32(387867788),
93    ];
94
95    LDWriter::new(&mut file, header)
96        .with_channel(channel0_meta, channel0_samples)
97        .with_channel(gps_lat_meta, gps_lat_samples)
98        .write()?;
99
100    Ok(())
101}

Trait Implementations§

Source§

impl<'a, S: Debug + Write + Seek> Debug for LDWriter<'a, S>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a, S> Freeze for LDWriter<'a, S>

§

impl<'a, S> RefUnwindSafe for LDWriter<'a, S>
where S: RefUnwindSafe,

§

impl<'a, S> Send for LDWriter<'a, S>
where S: Send,

§

impl<'a, S> Sync for LDWriter<'a, S>
where S: Sync,

§

impl<'a, S> Unpin for LDWriter<'a, S>

§

impl<'a, S> !UnwindSafe for LDWriter<'a, S>

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> 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, 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.