SLMPClient

Struct SLMPClient 

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

Implementations§

Source§

impl SLMPClient

Source

pub fn new(connection_props: SLMP4EConnectionProps) -> Self

Examples found in repository?
examples/bulk_access.rs (line 18)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let start_device: Device = Device{device_type: DeviceType::D, address: 0};
23
24    for i in 0..200 {
25        let data: Vec<TypedData> = [0u16; 120]
26            .iter()
27            .enumerate()
28            .map(|(j, _)| TypedData::U16(i as u16 + j as u16))
29            .collect();
30
31        client.bulk_write(start_device, &data).await.unwrap();
32
33        tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
34    }
35
36    let ret: Vec<DeviceData> = client.bulk_read(start_device, 8, DataType::U16).await.unwrap();
37    println!("\nDevice access:");
38    for x in ret {
39        println!("{:?}", x);
40    }
41
42    // Bit data
43    let start_device: Device = Device{device_type: DeviceType::M, address: 0};
44    let data = vec![
45        TypedData::Bool(true),
46        TypedData::Bool(false),
47        TypedData::Bool(false),
48        TypedData::Bool(true),
49    ];
50
51    client.bulk_write(start_device, &data).await.unwrap();
52
53    let ret: Vec<DeviceData> = client.bulk_read(start_device, data.len(), DataType::Bool).await.unwrap();
54    println!("\nBit access:");
55    for x in ret {
56        println!("{:?}", x);
57    }
58    println!();
59
60    client.close().await;
61}
More examples
Hide additional examples
examples/monitor_read.rs (line 18)
4async fn main() {
5    
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let devices = [
23        Device{device_type: DeviceType::D, address: 20},
24        Device{device_type: DeviceType::D, address: 25},
25        Device{device_type: DeviceType::D, address: 30},
26        Device{device_type: DeviceType::D, address: 35},
27    ];
28
29    let data = [
30        TypedData::U16(10),
31        TypedData::U16(20),
32        TypedData::I16(-40),
33        TypedData::U32(80000),
34    ];
35
36    let wr_data = [
37        DeviceData{device: devices[0], data: data[0]},
38        DeviceData{device: devices[1], data: data[1]},
39        DeviceData{device: devices[2], data: data[2]},
40        DeviceData{device: devices[3], data: data[3]},
41    ];
42    client.random_write(&wr_data).await.unwrap();
43
44    let devices = [
45        TypedDevice{device: devices[0], data_type: DataType::U16},
46        TypedDevice{device: devices[1], data_type: DataType::U16},
47        TypedDevice{device: devices[2], data_type: DataType::I16},
48        TypedDevice{device: devices[3], data_type: DataType::U32},
49    ];
50
51    let monitor_list = client.monitor_register(&devices).await.unwrap();
52
53    tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
54
55    let ret = client.monitor_read(&monitor_list).await.unwrap();
56
57    println!("\nDevice access:");
58    for x in ret {
59        println!("{:?}", x);
60    }
61
62    client.close().await;
63}
examples/block_access.rs (line 18)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    let data= [
22        BlockedDeviceData { 
23            access_type: AccessType::Word,
24            start_device: Device{device_type: DeviceType::D, address: 10},
25            data: &[ TypedData::U16(10), TypedData::U16(20) ]
26        },
27        BlockedDeviceData {
28            access_type: AccessType::Word,
29            start_device: Device{device_type: DeviceType::D, address: 20},
30            data: &[ TypedData::U16(30), TypedData::U16(40) ]
31        },
32        BlockedDeviceData {
33            access_type: AccessType::Bit,
34            start_device: Device{device_type: DeviceType::M, address: 0},
35            data: &[ TypedData::Bool(true), TypedData::Bool(false), TypedData::Bool(true) ]
36        },
37    ];
38    client.block_write(&data).await.unwrap();
39
40    let device_blocks = [
41        DeviceBlock{ access_type: data[0].access_type, start_device: data[0].start_device, size: data[0].data.len()},
42        DeviceBlock{ access_type: data[1].access_type, start_device: data[1].start_device, size: data[1].data.len()},
43        DeviceBlock{ access_type: data[2].access_type, start_device: data[2].start_device, size: data[2].data.len()},
44    ];
45
46    let ret: Vec<DeviceData> = client.block_read(&device_blocks).await.unwrap();
47    println!("\nDevice & Bit access:");
48    for data in ret {
49        println!("{:?}", data);
50    }
51    println!();
52
53    client.close().await;
54}
examples/random_access.rs (line 18)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Write
22    let devices = [
23        Device{device_type: DeviceType::D, address: 25},
24        Device{device_type: DeviceType::D, address: 20},
25        Device{device_type: DeviceType::D, address: 35},
26        Device{device_type: DeviceType::D, address: 30},
27        Device{device_type: DeviceType::M, address: 10},
28        Device{device_type: DeviceType::M, address: 11},
29        Device{device_type: DeviceType::M, address: 12},
30        Device{device_type: DeviceType::M, address: 13},
31    ];
32
33    let data = [
34        TypedData::U16(10),
35        TypedData::U16(20),
36        TypedData::U32(80000),
37        TypedData::I16(-40),
38        TypedData::Bool(true),
39        TypedData::Bool(false),
40        TypedData::Bool(true),
41        TypedData::Bool(true),
42    ];
43
44    let wr_data = [
45        DeviceData{device: devices[0], data: data[0]},
46        DeviceData{device: devices[2], data: data[2]},
47        DeviceData{device: devices[1], data: data[1]},
48        DeviceData{device: devices[3], data: data[3]},
49        DeviceData{device: devices[3], data: data[3]},
50        DeviceData{device: devices[1], data: data[1]},
51        DeviceData{device: devices[0], data: data[0]},
52        DeviceData{device: devices[2], data: data[2]},
53    ];
54    client.random_write(&wr_data).await.unwrap();
55
56    // Read
57    let devices = [
58        Device{device_type: DeviceType::D, address: 25},
59        Device{device_type: DeviceType::D, address: 20},
60        Device{device_type: DeviceType::D, address: 35},
61        Device{device_type: DeviceType::D, address: 30},
62        Device{device_type: DeviceType::M, address: 10},
63        Device{device_type: DeviceType::M, address: 11},
64        Device{device_type: DeviceType::M, address: 12},
65        Device{device_type: DeviceType::M, address: 13},
66    ];
67
68    let devices = [
69        TypedDevice{device: devices[0], data_type: DataType::U16},
70        TypedDevice{device: devices[1], data_type: DataType::U16},
71        TypedDevice{device: devices[2], data_type: DataType::U32},
72        TypedDevice{device: devices[3], data_type: DataType::I16},
73        TypedDevice{device: devices[7], data_type: DataType::Bool},
74        TypedDevice{device: devices[6], data_type: DataType::Bool},
75        TypedDevice{device: devices[5], data_type: DataType::Bool},
76        TypedDevice{device: devices[4], data_type: DataType::Bool},
77    ];
78
79    let ret = client.random_read(&devices).await.unwrap();
80    println!("\nDevice access:");
81    for x in ret {
82        println!("{:?}", x);
83    }
84    println!();
85
86
87    client.close().await;
88}
Source

pub async fn close(&self)

Examples found in repository?
examples/bulk_access.rs (line 60)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let start_device: Device = Device{device_type: DeviceType::D, address: 0};
23
24    for i in 0..200 {
25        let data: Vec<TypedData> = [0u16; 120]
26            .iter()
27            .enumerate()
28            .map(|(j, _)| TypedData::U16(i as u16 + j as u16))
29            .collect();
30
31        client.bulk_write(start_device, &data).await.unwrap();
32
33        tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
34    }
35
36    let ret: Vec<DeviceData> = client.bulk_read(start_device, 8, DataType::U16).await.unwrap();
37    println!("\nDevice access:");
38    for x in ret {
39        println!("{:?}", x);
40    }
41
42    // Bit data
43    let start_device: Device = Device{device_type: DeviceType::M, address: 0};
44    let data = vec![
45        TypedData::Bool(true),
46        TypedData::Bool(false),
47        TypedData::Bool(false),
48        TypedData::Bool(true),
49    ];
50
51    client.bulk_write(start_device, &data).await.unwrap();
52
53    let ret: Vec<DeviceData> = client.bulk_read(start_device, data.len(), DataType::Bool).await.unwrap();
54    println!("\nBit access:");
55    for x in ret {
56        println!("{:?}", x);
57    }
58    println!();
59
60    client.close().await;
61}
More examples
Hide additional examples
examples/monitor_read.rs (line 62)
4async fn main() {
5    
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let devices = [
23        Device{device_type: DeviceType::D, address: 20},
24        Device{device_type: DeviceType::D, address: 25},
25        Device{device_type: DeviceType::D, address: 30},
26        Device{device_type: DeviceType::D, address: 35},
27    ];
28
29    let data = [
30        TypedData::U16(10),
31        TypedData::U16(20),
32        TypedData::I16(-40),
33        TypedData::U32(80000),
34    ];
35
36    let wr_data = [
37        DeviceData{device: devices[0], data: data[0]},
38        DeviceData{device: devices[1], data: data[1]},
39        DeviceData{device: devices[2], data: data[2]},
40        DeviceData{device: devices[3], data: data[3]},
41    ];
42    client.random_write(&wr_data).await.unwrap();
43
44    let devices = [
45        TypedDevice{device: devices[0], data_type: DataType::U16},
46        TypedDevice{device: devices[1], data_type: DataType::U16},
47        TypedDevice{device: devices[2], data_type: DataType::I16},
48        TypedDevice{device: devices[3], data_type: DataType::U32},
49    ];
50
51    let monitor_list = client.monitor_register(&devices).await.unwrap();
52
53    tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
54
55    let ret = client.monitor_read(&monitor_list).await.unwrap();
56
57    println!("\nDevice access:");
58    for x in ret {
59        println!("{:?}", x);
60    }
61
62    client.close().await;
63}
examples/block_access.rs (line 53)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    let data= [
22        BlockedDeviceData { 
23            access_type: AccessType::Word,
24            start_device: Device{device_type: DeviceType::D, address: 10},
25            data: &[ TypedData::U16(10), TypedData::U16(20) ]
26        },
27        BlockedDeviceData {
28            access_type: AccessType::Word,
29            start_device: Device{device_type: DeviceType::D, address: 20},
30            data: &[ TypedData::U16(30), TypedData::U16(40) ]
31        },
32        BlockedDeviceData {
33            access_type: AccessType::Bit,
34            start_device: Device{device_type: DeviceType::M, address: 0},
35            data: &[ TypedData::Bool(true), TypedData::Bool(false), TypedData::Bool(true) ]
36        },
37    ];
38    client.block_write(&data).await.unwrap();
39
40    let device_blocks = [
41        DeviceBlock{ access_type: data[0].access_type, start_device: data[0].start_device, size: data[0].data.len()},
42        DeviceBlock{ access_type: data[1].access_type, start_device: data[1].start_device, size: data[1].data.len()},
43        DeviceBlock{ access_type: data[2].access_type, start_device: data[2].start_device, size: data[2].data.len()},
44    ];
45
46    let ret: Vec<DeviceData> = client.block_read(&device_blocks).await.unwrap();
47    println!("\nDevice & Bit access:");
48    for data in ret {
49        println!("{:?}", data);
50    }
51    println!();
52
53    client.close().await;
54}
examples/random_access.rs (line 87)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Write
22    let devices = [
23        Device{device_type: DeviceType::D, address: 25},
24        Device{device_type: DeviceType::D, address: 20},
25        Device{device_type: DeviceType::D, address: 35},
26        Device{device_type: DeviceType::D, address: 30},
27        Device{device_type: DeviceType::M, address: 10},
28        Device{device_type: DeviceType::M, address: 11},
29        Device{device_type: DeviceType::M, address: 12},
30        Device{device_type: DeviceType::M, address: 13},
31    ];
32
33    let data = [
34        TypedData::U16(10),
35        TypedData::U16(20),
36        TypedData::U32(80000),
37        TypedData::I16(-40),
38        TypedData::Bool(true),
39        TypedData::Bool(false),
40        TypedData::Bool(true),
41        TypedData::Bool(true),
42    ];
43
44    let wr_data = [
45        DeviceData{device: devices[0], data: data[0]},
46        DeviceData{device: devices[2], data: data[2]},
47        DeviceData{device: devices[1], data: data[1]},
48        DeviceData{device: devices[3], data: data[3]},
49        DeviceData{device: devices[3], data: data[3]},
50        DeviceData{device: devices[1], data: data[1]},
51        DeviceData{device: devices[0], data: data[0]},
52        DeviceData{device: devices[2], data: data[2]},
53    ];
54    client.random_write(&wr_data).await.unwrap();
55
56    // Read
57    let devices = [
58        Device{device_type: DeviceType::D, address: 25},
59        Device{device_type: DeviceType::D, address: 20},
60        Device{device_type: DeviceType::D, address: 35},
61        Device{device_type: DeviceType::D, address: 30},
62        Device{device_type: DeviceType::M, address: 10},
63        Device{device_type: DeviceType::M, address: 11},
64        Device{device_type: DeviceType::M, address: 12},
65        Device{device_type: DeviceType::M, address: 13},
66    ];
67
68    let devices = [
69        TypedDevice{device: devices[0], data_type: DataType::U16},
70        TypedDevice{device: devices[1], data_type: DataType::U16},
71        TypedDevice{device: devices[2], data_type: DataType::U32},
72        TypedDevice{device: devices[3], data_type: DataType::I16},
73        TypedDevice{device: devices[7], data_type: DataType::Bool},
74        TypedDevice{device: devices[6], data_type: DataType::Bool},
75        TypedDevice{device: devices[5], data_type: DataType::Bool},
76        TypedDevice{device: devices[4], data_type: DataType::Bool},
77    ];
78
79    let ret = client.random_read(&devices).await.unwrap();
80    println!("\nDevice access:");
81    for x in ret {
82        println!("{:?}", x);
83    }
84    println!();
85
86
87    client.close().await;
88}
Source

pub fn set_send_timeout(&mut self, dur: Duration)

Source

pub fn set_recv_timeout(&mut self, dur: Duration)

Source

pub async fn connect(&self) -> Result<()>

Examples found in repository?
examples/bulk_access.rs (line 19)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let start_device: Device = Device{device_type: DeviceType::D, address: 0};
23
24    for i in 0..200 {
25        let data: Vec<TypedData> = [0u16; 120]
26            .iter()
27            .enumerate()
28            .map(|(j, _)| TypedData::U16(i as u16 + j as u16))
29            .collect();
30
31        client.bulk_write(start_device, &data).await.unwrap();
32
33        tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
34    }
35
36    let ret: Vec<DeviceData> = client.bulk_read(start_device, 8, DataType::U16).await.unwrap();
37    println!("\nDevice access:");
38    for x in ret {
39        println!("{:?}", x);
40    }
41
42    // Bit data
43    let start_device: Device = Device{device_type: DeviceType::M, address: 0};
44    let data = vec![
45        TypedData::Bool(true),
46        TypedData::Bool(false),
47        TypedData::Bool(false),
48        TypedData::Bool(true),
49    ];
50
51    client.bulk_write(start_device, &data).await.unwrap();
52
53    let ret: Vec<DeviceData> = client.bulk_read(start_device, data.len(), DataType::Bool).await.unwrap();
54    println!("\nBit access:");
55    for x in ret {
56        println!("{:?}", x);
57    }
58    println!();
59
60    client.close().await;
61}
More examples
Hide additional examples
examples/monitor_read.rs (line 19)
4async fn main() {
5    
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let devices = [
23        Device{device_type: DeviceType::D, address: 20},
24        Device{device_type: DeviceType::D, address: 25},
25        Device{device_type: DeviceType::D, address: 30},
26        Device{device_type: DeviceType::D, address: 35},
27    ];
28
29    let data = [
30        TypedData::U16(10),
31        TypedData::U16(20),
32        TypedData::I16(-40),
33        TypedData::U32(80000),
34    ];
35
36    let wr_data = [
37        DeviceData{device: devices[0], data: data[0]},
38        DeviceData{device: devices[1], data: data[1]},
39        DeviceData{device: devices[2], data: data[2]},
40        DeviceData{device: devices[3], data: data[3]},
41    ];
42    client.random_write(&wr_data).await.unwrap();
43
44    let devices = [
45        TypedDevice{device: devices[0], data_type: DataType::U16},
46        TypedDevice{device: devices[1], data_type: DataType::U16},
47        TypedDevice{device: devices[2], data_type: DataType::I16},
48        TypedDevice{device: devices[3], data_type: DataType::U32},
49    ];
50
51    let monitor_list = client.monitor_register(&devices).await.unwrap();
52
53    tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
54
55    let ret = client.monitor_read(&monitor_list).await.unwrap();
56
57    println!("\nDevice access:");
58    for x in ret {
59        println!("{:?}", x);
60    }
61
62    client.close().await;
63}
examples/block_access.rs (line 19)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    let data= [
22        BlockedDeviceData { 
23            access_type: AccessType::Word,
24            start_device: Device{device_type: DeviceType::D, address: 10},
25            data: &[ TypedData::U16(10), TypedData::U16(20) ]
26        },
27        BlockedDeviceData {
28            access_type: AccessType::Word,
29            start_device: Device{device_type: DeviceType::D, address: 20},
30            data: &[ TypedData::U16(30), TypedData::U16(40) ]
31        },
32        BlockedDeviceData {
33            access_type: AccessType::Bit,
34            start_device: Device{device_type: DeviceType::M, address: 0},
35            data: &[ TypedData::Bool(true), TypedData::Bool(false), TypedData::Bool(true) ]
36        },
37    ];
38    client.block_write(&data).await.unwrap();
39
40    let device_blocks = [
41        DeviceBlock{ access_type: data[0].access_type, start_device: data[0].start_device, size: data[0].data.len()},
42        DeviceBlock{ access_type: data[1].access_type, start_device: data[1].start_device, size: data[1].data.len()},
43        DeviceBlock{ access_type: data[2].access_type, start_device: data[2].start_device, size: data[2].data.len()},
44    ];
45
46    let ret: Vec<DeviceData> = client.block_read(&device_blocks).await.unwrap();
47    println!("\nDevice & Bit access:");
48    for data in ret {
49        println!("{:?}", data);
50    }
51    println!();
52
53    client.close().await;
54}
examples/random_access.rs (line 19)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Write
22    let devices = [
23        Device{device_type: DeviceType::D, address: 25},
24        Device{device_type: DeviceType::D, address: 20},
25        Device{device_type: DeviceType::D, address: 35},
26        Device{device_type: DeviceType::D, address: 30},
27        Device{device_type: DeviceType::M, address: 10},
28        Device{device_type: DeviceType::M, address: 11},
29        Device{device_type: DeviceType::M, address: 12},
30        Device{device_type: DeviceType::M, address: 13},
31    ];
32
33    let data = [
34        TypedData::U16(10),
35        TypedData::U16(20),
36        TypedData::U32(80000),
37        TypedData::I16(-40),
38        TypedData::Bool(true),
39        TypedData::Bool(false),
40        TypedData::Bool(true),
41        TypedData::Bool(true),
42    ];
43
44    let wr_data = [
45        DeviceData{device: devices[0], data: data[0]},
46        DeviceData{device: devices[2], data: data[2]},
47        DeviceData{device: devices[1], data: data[1]},
48        DeviceData{device: devices[3], data: data[3]},
49        DeviceData{device: devices[3], data: data[3]},
50        DeviceData{device: devices[1], data: data[1]},
51        DeviceData{device: devices[0], data: data[0]},
52        DeviceData{device: devices[2], data: data[2]},
53    ];
54    client.random_write(&wr_data).await.unwrap();
55
56    // Read
57    let devices = [
58        Device{device_type: DeviceType::D, address: 25},
59        Device{device_type: DeviceType::D, address: 20},
60        Device{device_type: DeviceType::D, address: 35},
61        Device{device_type: DeviceType::D, address: 30},
62        Device{device_type: DeviceType::M, address: 10},
63        Device{device_type: DeviceType::M, address: 11},
64        Device{device_type: DeviceType::M, address: 12},
65        Device{device_type: DeviceType::M, address: 13},
66    ];
67
68    let devices = [
69        TypedDevice{device: devices[0], data_type: DataType::U16},
70        TypedDevice{device: devices[1], data_type: DataType::U16},
71        TypedDevice{device: devices[2], data_type: DataType::U32},
72        TypedDevice{device: devices[3], data_type: DataType::I16},
73        TypedDevice{device: devices[7], data_type: DataType::Bool},
74        TypedDevice{device: devices[6], data_type: DataType::Bool},
75        TypedDevice{device: devices[5], data_type: DataType::Bool},
76        TypedDevice{device: devices[4], data_type: DataType::Bool},
77    ];
78
79    let ret = client.random_read(&devices).await.unwrap();
80    println!("\nDevice access:");
81    for x in ret {
82        println!("{:?}", x);
83    }
84    println!();
85
86
87    client.close().await;
88}
Source

pub async fn bulk_write<'a>( &mut self, start_device: Device, data: &'a [TypedData], ) -> Result<()>

Examples found in repository?
examples/bulk_access.rs (line 31)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let start_device: Device = Device{device_type: DeviceType::D, address: 0};
23
24    for i in 0..200 {
25        let data: Vec<TypedData> = [0u16; 120]
26            .iter()
27            .enumerate()
28            .map(|(j, _)| TypedData::U16(i as u16 + j as u16))
29            .collect();
30
31        client.bulk_write(start_device, &data).await.unwrap();
32
33        tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
34    }
35
36    let ret: Vec<DeviceData> = client.bulk_read(start_device, 8, DataType::U16).await.unwrap();
37    println!("\nDevice access:");
38    for x in ret {
39        println!("{:?}", x);
40    }
41
42    // Bit data
43    let start_device: Device = Device{device_type: DeviceType::M, address: 0};
44    let data = vec![
45        TypedData::Bool(true),
46        TypedData::Bool(false),
47        TypedData::Bool(false),
48        TypedData::Bool(true),
49    ];
50
51    client.bulk_write(start_device, &data).await.unwrap();
52
53    let ret: Vec<DeviceData> = client.bulk_read(start_device, data.len(), DataType::Bool).await.unwrap();
54    println!("\nBit access:");
55    for x in ret {
56        println!("{:?}", x);
57    }
58    println!();
59
60    client.close().await;
61}
Source

pub async fn random_write<'a>(&mut self, data: &'a [DeviceData]) -> Result<()>

Examples found in repository?
examples/monitor_read.rs (line 42)
4async fn main() {
5    
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let devices = [
23        Device{device_type: DeviceType::D, address: 20},
24        Device{device_type: DeviceType::D, address: 25},
25        Device{device_type: DeviceType::D, address: 30},
26        Device{device_type: DeviceType::D, address: 35},
27    ];
28
29    let data = [
30        TypedData::U16(10),
31        TypedData::U16(20),
32        TypedData::I16(-40),
33        TypedData::U32(80000),
34    ];
35
36    let wr_data = [
37        DeviceData{device: devices[0], data: data[0]},
38        DeviceData{device: devices[1], data: data[1]},
39        DeviceData{device: devices[2], data: data[2]},
40        DeviceData{device: devices[3], data: data[3]},
41    ];
42    client.random_write(&wr_data).await.unwrap();
43
44    let devices = [
45        TypedDevice{device: devices[0], data_type: DataType::U16},
46        TypedDevice{device: devices[1], data_type: DataType::U16},
47        TypedDevice{device: devices[2], data_type: DataType::I16},
48        TypedDevice{device: devices[3], data_type: DataType::U32},
49    ];
50
51    let monitor_list = client.monitor_register(&devices).await.unwrap();
52
53    tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
54
55    let ret = client.monitor_read(&monitor_list).await.unwrap();
56
57    println!("\nDevice access:");
58    for x in ret {
59        println!("{:?}", x);
60    }
61
62    client.close().await;
63}
More examples
Hide additional examples
examples/random_access.rs (line 54)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Write
22    let devices = [
23        Device{device_type: DeviceType::D, address: 25},
24        Device{device_type: DeviceType::D, address: 20},
25        Device{device_type: DeviceType::D, address: 35},
26        Device{device_type: DeviceType::D, address: 30},
27        Device{device_type: DeviceType::M, address: 10},
28        Device{device_type: DeviceType::M, address: 11},
29        Device{device_type: DeviceType::M, address: 12},
30        Device{device_type: DeviceType::M, address: 13},
31    ];
32
33    let data = [
34        TypedData::U16(10),
35        TypedData::U16(20),
36        TypedData::U32(80000),
37        TypedData::I16(-40),
38        TypedData::Bool(true),
39        TypedData::Bool(false),
40        TypedData::Bool(true),
41        TypedData::Bool(true),
42    ];
43
44    let wr_data = [
45        DeviceData{device: devices[0], data: data[0]},
46        DeviceData{device: devices[2], data: data[2]},
47        DeviceData{device: devices[1], data: data[1]},
48        DeviceData{device: devices[3], data: data[3]},
49        DeviceData{device: devices[3], data: data[3]},
50        DeviceData{device: devices[1], data: data[1]},
51        DeviceData{device: devices[0], data: data[0]},
52        DeviceData{device: devices[2], data: data[2]},
53    ];
54    client.random_write(&wr_data).await.unwrap();
55
56    // Read
57    let devices = [
58        Device{device_type: DeviceType::D, address: 25},
59        Device{device_type: DeviceType::D, address: 20},
60        Device{device_type: DeviceType::D, address: 35},
61        Device{device_type: DeviceType::D, address: 30},
62        Device{device_type: DeviceType::M, address: 10},
63        Device{device_type: DeviceType::M, address: 11},
64        Device{device_type: DeviceType::M, address: 12},
65        Device{device_type: DeviceType::M, address: 13},
66    ];
67
68    let devices = [
69        TypedDevice{device: devices[0], data_type: DataType::U16},
70        TypedDevice{device: devices[1], data_type: DataType::U16},
71        TypedDevice{device: devices[2], data_type: DataType::U32},
72        TypedDevice{device: devices[3], data_type: DataType::I16},
73        TypedDevice{device: devices[7], data_type: DataType::Bool},
74        TypedDevice{device: devices[6], data_type: DataType::Bool},
75        TypedDevice{device: devices[5], data_type: DataType::Bool},
76        TypedDevice{device: devices[4], data_type: DataType::Bool},
77    ];
78
79    let ret = client.random_read(&devices).await.unwrap();
80    println!("\nDevice access:");
81    for x in ret {
82        println!("{:?}", x);
83    }
84    println!();
85
86
87    client.close().await;
88}
Source

pub async fn block_write<'a>( &mut self, data: &'a [BlockedDeviceData<'a>], ) -> Result<()>

Examples found in repository?
examples/block_access.rs (line 38)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    let data= [
22        BlockedDeviceData { 
23            access_type: AccessType::Word,
24            start_device: Device{device_type: DeviceType::D, address: 10},
25            data: &[ TypedData::U16(10), TypedData::U16(20) ]
26        },
27        BlockedDeviceData {
28            access_type: AccessType::Word,
29            start_device: Device{device_type: DeviceType::D, address: 20},
30            data: &[ TypedData::U16(30), TypedData::U16(40) ]
31        },
32        BlockedDeviceData {
33            access_type: AccessType::Bit,
34            start_device: Device{device_type: DeviceType::M, address: 0},
35            data: &[ TypedData::Bool(true), TypedData::Bool(false), TypedData::Bool(true) ]
36        },
37    ];
38    client.block_write(&data).await.unwrap();
39
40    let device_blocks = [
41        DeviceBlock{ access_type: data[0].access_type, start_device: data[0].start_device, size: data[0].data.len()},
42        DeviceBlock{ access_type: data[1].access_type, start_device: data[1].start_device, size: data[1].data.len()},
43        DeviceBlock{ access_type: data[2].access_type, start_device: data[2].start_device, size: data[2].data.len()},
44    ];
45
46    let ret: Vec<DeviceData> = client.block_read(&device_blocks).await.unwrap();
47    println!("\nDevice & Bit access:");
48    for data in ret {
49        println!("{:?}", data);
50    }
51    println!();
52
53    client.close().await;
54}
Source

pub async fn bulk_read( &mut self, start_device: Device, device_num: usize, data_type: DataType, ) -> Result<Vec<DeviceData>>

Examples found in repository?
examples/bulk_access.rs (line 36)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let start_device: Device = Device{device_type: DeviceType::D, address: 0};
23
24    for i in 0..200 {
25        let data: Vec<TypedData> = [0u16; 120]
26            .iter()
27            .enumerate()
28            .map(|(j, _)| TypedData::U16(i as u16 + j as u16))
29            .collect();
30
31        client.bulk_write(start_device, &data).await.unwrap();
32
33        tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
34    }
35
36    let ret: Vec<DeviceData> = client.bulk_read(start_device, 8, DataType::U16).await.unwrap();
37    println!("\nDevice access:");
38    for x in ret {
39        println!("{:?}", x);
40    }
41
42    // Bit data
43    let start_device: Device = Device{device_type: DeviceType::M, address: 0};
44    let data = vec![
45        TypedData::Bool(true),
46        TypedData::Bool(false),
47        TypedData::Bool(false),
48        TypedData::Bool(true),
49    ];
50
51    client.bulk_write(start_device, &data).await.unwrap();
52
53    let ret: Vec<DeviceData> = client.bulk_read(start_device, data.len(), DataType::Bool).await.unwrap();
54    println!("\nBit access:");
55    for x in ret {
56        println!("{:?}", x);
57    }
58    println!();
59
60    client.close().await;
61}
Source

pub async fn random_read( &mut self, devices: &[TypedDevice], ) -> Result<Vec<DeviceData>>

Examples found in repository?
examples/random_access.rs (line 79)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Write
22    let devices = [
23        Device{device_type: DeviceType::D, address: 25},
24        Device{device_type: DeviceType::D, address: 20},
25        Device{device_type: DeviceType::D, address: 35},
26        Device{device_type: DeviceType::D, address: 30},
27        Device{device_type: DeviceType::M, address: 10},
28        Device{device_type: DeviceType::M, address: 11},
29        Device{device_type: DeviceType::M, address: 12},
30        Device{device_type: DeviceType::M, address: 13},
31    ];
32
33    let data = [
34        TypedData::U16(10),
35        TypedData::U16(20),
36        TypedData::U32(80000),
37        TypedData::I16(-40),
38        TypedData::Bool(true),
39        TypedData::Bool(false),
40        TypedData::Bool(true),
41        TypedData::Bool(true),
42    ];
43
44    let wr_data = [
45        DeviceData{device: devices[0], data: data[0]},
46        DeviceData{device: devices[2], data: data[2]},
47        DeviceData{device: devices[1], data: data[1]},
48        DeviceData{device: devices[3], data: data[3]},
49        DeviceData{device: devices[3], data: data[3]},
50        DeviceData{device: devices[1], data: data[1]},
51        DeviceData{device: devices[0], data: data[0]},
52        DeviceData{device: devices[2], data: data[2]},
53    ];
54    client.random_write(&wr_data).await.unwrap();
55
56    // Read
57    let devices = [
58        Device{device_type: DeviceType::D, address: 25},
59        Device{device_type: DeviceType::D, address: 20},
60        Device{device_type: DeviceType::D, address: 35},
61        Device{device_type: DeviceType::D, address: 30},
62        Device{device_type: DeviceType::M, address: 10},
63        Device{device_type: DeviceType::M, address: 11},
64        Device{device_type: DeviceType::M, address: 12},
65        Device{device_type: DeviceType::M, address: 13},
66    ];
67
68    let devices = [
69        TypedDevice{device: devices[0], data_type: DataType::U16},
70        TypedDevice{device: devices[1], data_type: DataType::U16},
71        TypedDevice{device: devices[2], data_type: DataType::U32},
72        TypedDevice{device: devices[3], data_type: DataType::I16},
73        TypedDevice{device: devices[7], data_type: DataType::Bool},
74        TypedDevice{device: devices[6], data_type: DataType::Bool},
75        TypedDevice{device: devices[5], data_type: DataType::Bool},
76        TypedDevice{device: devices[4], data_type: DataType::Bool},
77    ];
78
79    let ret = client.random_read(&devices).await.unwrap();
80    println!("\nDevice access:");
81    for x in ret {
82        println!("{:?}", x);
83    }
84    println!();
85
86
87    client.close().await;
88}
Source

pub async fn block_read( &mut self, device_blocks: &[DeviceBlock], ) -> Result<Vec<DeviceData>>

Examples found in repository?
examples/block_access.rs (line 46)
4async fn main() {
5
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    let data= [
22        BlockedDeviceData { 
23            access_type: AccessType::Word,
24            start_device: Device{device_type: DeviceType::D, address: 10},
25            data: &[ TypedData::U16(10), TypedData::U16(20) ]
26        },
27        BlockedDeviceData {
28            access_type: AccessType::Word,
29            start_device: Device{device_type: DeviceType::D, address: 20},
30            data: &[ TypedData::U16(30), TypedData::U16(40) ]
31        },
32        BlockedDeviceData {
33            access_type: AccessType::Bit,
34            start_device: Device{device_type: DeviceType::M, address: 0},
35            data: &[ TypedData::Bool(true), TypedData::Bool(false), TypedData::Bool(true) ]
36        },
37    ];
38    client.block_write(&data).await.unwrap();
39
40    let device_blocks = [
41        DeviceBlock{ access_type: data[0].access_type, start_device: data[0].start_device, size: data[0].data.len()},
42        DeviceBlock{ access_type: data[1].access_type, start_device: data[1].start_device, size: data[1].data.len()},
43        DeviceBlock{ access_type: data[2].access_type, start_device: data[2].start_device, size: data[2].data.len()},
44    ];
45
46    let ret: Vec<DeviceData> = client.block_read(&device_blocks).await.unwrap();
47    println!("\nDevice & Bit access:");
48    for data in ret {
49        println!("{:?}", data);
50    }
51    println!();
52
53    client.close().await;
54}
Source

pub async fn monitor_register( &mut self, devices: &[TypedDevice], ) -> Result<MonitorList>

Examples found in repository?
examples/monitor_read.rs (line 51)
4async fn main() {
5    
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let devices = [
23        Device{device_type: DeviceType::D, address: 20},
24        Device{device_type: DeviceType::D, address: 25},
25        Device{device_type: DeviceType::D, address: 30},
26        Device{device_type: DeviceType::D, address: 35},
27    ];
28
29    let data = [
30        TypedData::U16(10),
31        TypedData::U16(20),
32        TypedData::I16(-40),
33        TypedData::U32(80000),
34    ];
35
36    let wr_data = [
37        DeviceData{device: devices[0], data: data[0]},
38        DeviceData{device: devices[1], data: data[1]},
39        DeviceData{device: devices[2], data: data[2]},
40        DeviceData{device: devices[3], data: data[3]},
41    ];
42    client.random_write(&wr_data).await.unwrap();
43
44    let devices = [
45        TypedDevice{device: devices[0], data_type: DataType::U16},
46        TypedDevice{device: devices[1], data_type: DataType::U16},
47        TypedDevice{device: devices[2], data_type: DataType::I16},
48        TypedDevice{device: devices[3], data_type: DataType::U32},
49    ];
50
51    let monitor_list = client.monitor_register(&devices).await.unwrap();
52
53    tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
54
55    let ret = client.monitor_read(&monitor_list).await.unwrap();
56
57    println!("\nDevice access:");
58    for x in ret {
59        println!("{:?}", x);
60    }
61
62    client.close().await;
63}
Source

pub async fn monitor_read( &mut self, monitor_list: &MonitorList, ) -> Result<Vec<DeviceData>>

Examples found in repository?
examples/monitor_read.rs (line 55)
4async fn main() {
5    
6    let connection_props: SLMP4EConnectionProps = SLMP4EConnectionProps {
7        ip: String::from("192.168.3.10"),
8        port: 5007,
9        cpu: CPU::R,
10        serial_id: 0x0001,
11        network_id: 0x00,
12        pc_id: 0xff,
13        io_id: 0x03ff,
14        area_id: 0x00,
15        cpu_timer: 0x0010,
16    };
17
18    let mut client = SLMPClient::new(connection_props);
19    client.connect().await.unwrap();
20
21    // Word data
22    let devices = [
23        Device{device_type: DeviceType::D, address: 20},
24        Device{device_type: DeviceType::D, address: 25},
25        Device{device_type: DeviceType::D, address: 30},
26        Device{device_type: DeviceType::D, address: 35},
27    ];
28
29    let data = [
30        TypedData::U16(10),
31        TypedData::U16(20),
32        TypedData::I16(-40),
33        TypedData::U32(80000),
34    ];
35
36    let wr_data = [
37        DeviceData{device: devices[0], data: data[0]},
38        DeviceData{device: devices[1], data: data[1]},
39        DeviceData{device: devices[2], data: data[2]},
40        DeviceData{device: devices[3], data: data[3]},
41    ];
42    client.random_write(&wr_data).await.unwrap();
43
44    let devices = [
45        TypedDevice{device: devices[0], data_type: DataType::U16},
46        TypedDevice{device: devices[1], data_type: DataType::U16},
47        TypedDevice{device: devices[2], data_type: DataType::I16},
48        TypedDevice{device: devices[3], data_type: DataType::U32},
49    ];
50
51    let monitor_list = client.monitor_register(&devices).await.unwrap();
52
53    tokio::time::sleep(tokio::time::Duration::from_millis(100)).await;
54
55    let ret = client.monitor_read(&monitor_list).await.unwrap();
56
57    println!("\nDevice access:");
58    for x in ret {
59        println!("{:?}", x);
60    }
61
62    client.close().await;
63}

Trait Implementations§

Source§

impl Clone for SLMPClient

Source§

fn clone(&self) -> SLMPClient

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

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

Performs copy-assignment from source. Read more

Auto Trait Implementations§

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.