Skip to content

Commit b65baee

Browse files
muwo-barenhoffbirkenfeld
authored andcommitted
update dependency versions and toolchain
1 parent 7d4ca8a commit b65baee

File tree

10 files changed

+54
-38
lines changed

10 files changed

+54
-38
lines changed

CHANGELOG.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## 0.5.0 -- unreleased
44

5-
- Rust 1.58 is now required.
5+
- Rust 1.63 is now required.
66
- Fixed-length string types in `ads::strings` are now using const generics
77
instead of macro-created types.
88
- Array bounds can be negative, change type in symbol info (#13).

Cargo.toml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@ repository = "https://github.com/birkenfeld/ads-rs"
99
keywords = ["Beckhoff", "ADS", "automation", "device", "PLC"]
1010

1111
[dependencies]
12-
byteorder = "1.4.3"
13-
crossbeam-channel = "0.5.1"
14-
itertools = "0.10.1"
15-
thiserror = "1.0.39"
16-
zerocopy = "0.6.1"
12+
byteorder = "1.5.0"
13+
crossbeam-channel = "0.5.13"
14+
itertools = "0.13.0"
15+
thiserror = "1.0.63"
16+
zerocopy = { version = "0.7.35", features = ["derive"] }
1717

1818
[dev-dependencies]
19-
once_cell = "1.14.0"
19+
once_cell = "1.19.0"
2020
parse_int = "0.6.0"
21-
quick-xml = "0.23.0"
22-
regex = "1.5.4"
23-
structopt = "0.3.25"
24-
strum = { version = "0.24", features = ["derive"] }
25-
time = { version = "<0.3.14", features = ["formatting"] }
21+
quick-xml = "0.36.1"
22+
regex = "<1.10.0"
23+
structopt = "0.3.26"
24+
strum = { version = "0.26.3", features = ["derive"] }
25+
time = { version = "<0.3.21", features = ["formatting"] }

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ ads = "0.4"
1818

1919
### Rust version
2020

21-
Minimum supported Rust version is 1.58.1.
21+
Minimum supported Rust version is 1.63.0.
2222

2323
## Usage
2424

examples/adstool.rs

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ use itertools::Itertools;
99
use parse_int::parse;
1010
use structopt::{clap::AppSettings, clap::ArgGroup, StructOpt};
1111
use strum::EnumString;
12-
use quick_xml::events::Event;
12+
use quick_xml::{events::Event, name::QName};
1313
use time::OffsetDateTime;
1414

1515
#[derive(StructOpt, Debug)]
@@ -418,17 +418,16 @@ fn main_inner(args: Args) -> Result<(), Error> {
418418
let mut xml = [0; 2048];
419419
dev.read(ads::index::TARGET_DESC, 1, &mut xml)?;
420420
let mut rdr = quick_xml::Reader::from_reader(&xml[..]);
421-
rdr.trim_text(true);
422-
let mut buf = Vec::new();
421+
rdr.config_mut().trim_text(true);
423422
let mut stack = Vec::new();
424423
loop {
425-
match rdr.read_event(&mut buf) {
426-
Ok(Event::Start(el)) => if el.name() != b"TcTargetDesc" {
427-
stack.push(String::from_utf8_lossy(el.name()).to_string());
424+
match rdr.read_event() {
425+
Ok(Event::Start(el)) => if el.name() != QName(b"TcTargetDesc") {
426+
stack.push(String::from_utf8_lossy(el.name().0).to_string());
428427
}
429428
Ok(Event::End(_)) => { let _ = stack.pop(); }
430429
Ok(Event::Text(t)) => if !stack.is_empty() {
431-
println!("{}: {}", stack.iter().format("."), String::from_utf8_lossy(t.escaped()));
430+
println!("{}: {}", stack.iter().format("."), String::from_utf8_lossy(&t));
432431
}
433432
Ok(Event::Eof) => break,
434433
Err(e) => return Err(Error::Str(format!("error parsing target desc XML: {}", e))),

rust-toolchain

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
1.58.1
1+
1.63.0

src/client.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use crate::notif;
1818
use crate::{AmsAddr, AmsNetId, Error, Result};
1919

2020
use zerocopy::byteorder::{U16, U32};
21-
use zerocopy::{AsBytes, FromBytes};
21+
use zerocopy::{AsBytes, FromBytes, FromZeroes};
2222

2323
/// An ADS protocol command.
2424
// https://infosys.beckhoff.com/content/1033/tc3_ads_intro/115847307.html?id=7738940192708835096
@@ -979,7 +979,7 @@ impl FromStr for AdsState {
979979
// Structures used in communication, not exposed to user,
980980
// but pub(crate) for the test suite.
981981

982-
#[derive(AsBytes, FromBytes, Debug)]
982+
#[derive(AsBytes, FromBytes, FromZeroes, Debug)]
983983
#[repr(C)]
984984
pub(crate) struct AdsHeader {
985985
/// 0x0 - ADS command
@@ -1009,7 +1009,7 @@ pub(crate) struct AdsHeader {
10091009
pub invoke_id: U32<LE>,
10101010
}
10111011

1012-
#[derive(FromBytes, AsBytes)]
1012+
#[derive(FromBytes, FromZeroes, AsBytes)]
10131013
#[repr(C)]
10141014
pub(crate) struct DeviceInfoRaw {
10151015
pub major: u8,
@@ -1018,22 +1018,22 @@ pub(crate) struct DeviceInfoRaw {
10181018
pub name: [u8; 16],
10191019
}
10201020

1021-
#[derive(FromBytes, AsBytes)]
1021+
#[derive(FromBytes, FromZeroes, AsBytes)]
10221022
#[repr(C)]
10231023
pub(crate) struct IndexLength {
10241024
pub index_group: U32<LE>,
10251025
pub index_offset: U32<LE>,
10261026
pub length: U32<LE>,
10271027
}
10281028

1029-
#[derive(FromBytes, AsBytes)]
1029+
#[derive(FromBytes, FromZeroes, AsBytes)]
10301030
#[repr(C)]
10311031
pub(crate) struct ResultLength {
10321032
pub result: U32<LE>,
10331033
pub length: U32<LE>,
10341034
}
10351035

1036-
#[derive(FromBytes, AsBytes)]
1036+
#[derive(FromBytes, FromZeroes, AsBytes)]
10371037
#[repr(C)]
10381038
pub(crate) struct IndexLengthRW {
10391039
pub index_group: U32<LE>,
@@ -1042,22 +1042,22 @@ pub(crate) struct IndexLengthRW {
10421042
pub write_length: U32<LE>,
10431043
}
10441044

1045-
#[derive(FromBytes, AsBytes)]
1045+
#[derive(FromBytes, FromZeroes, AsBytes)]
10461046
#[repr(C)]
10471047
pub(crate) struct ReadState {
10481048
pub ads_state: U16<LE>,
10491049
pub dev_state: U16<LE>,
10501050
}
10511051

1052-
#[derive(FromBytes, AsBytes)]
1052+
#[derive(FromBytes, FromZeroes, AsBytes)]
10531053
#[repr(C)]
10541054
pub(crate) struct WriteControl {
10551055
pub ads_state: U16<LE>,
10561056
pub dev_state: U16<LE>,
10571057
pub data_length: U32<LE>,
10581058
}
10591059

1060-
#[derive(FromBytes, AsBytes)]
1060+
#[derive(FromBytes, FromZeroes, AsBytes)]
10611061
#[repr(C)]
10621062
pub(crate) struct AddNotif {
10631063
pub index_group: U32<LE>,

src/netid.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use std::str::FromStr;
88

99
use byteorder::{ReadBytesExt, WriteBytesExt, LE};
1010
use itertools::Itertools;
11-
use zerocopy::{AsBytes, FromBytes};
11+
use zerocopy::{AsBytes, FromBytes, FromZeroes};
1212

1313
/// Represents an AMS NetID.
1414
///
@@ -19,7 +19,8 @@ use zerocopy::{AsBytes, FromBytes};
1919
/// Although often the first 4 bytes of a NetID look like an IP address, and
2020
/// sometimes even are identical to the device's IP address, there is no
2121
/// requirement for this, and one should never rely on it.
22-
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Debug, AsBytes, FromBytes)]
22+
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Default, Debug,
23+
AsBytes, FromZeroes, FromBytes)]
2324
#[repr(C)]
2425
pub struct AmsNetId(pub [u8; 6]);
2526

src/strings.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,11 @@ impl<const LEN: usize> String<LEN> {
2424
self.0.iter().position(|&b| b == 0).unwrap_or(self.0.len())
2525
}
2626

27+
/// Returns true if the string is empty.
28+
pub fn is_empty(&self) -> bool {
29+
self.len() == 0
30+
}
31+
2732
/// Get the slice up to the first null byte.
2833
pub fn as_bytes(&self) -> &[u8] {
2934
&self.0[..self.len()]
@@ -123,10 +128,13 @@ unsafe impl<const LEN: usize> zerocopy::AsBytes for String<LEN> {
123128
fn only_derive_is_allowed_to_implement_this_trait() { }
124129
}
125130

126-
unsafe impl<const LEN: usize> zerocopy::FromBytes for String<LEN> {
131+
unsafe impl<const LEN: usize> zerocopy::FromZeroes for String<LEN> {
127132
fn only_derive_is_allowed_to_implement_this_trait() { }
128133
}
129134

135+
unsafe impl<const LEN: usize> zerocopy::FromBytes for String<LEN> {
136+
fn only_derive_is_allowed_to_implement_this_trait() { }
137+
}
130138

131139
/// Represents a fixed-length wide string.
132140
///
@@ -154,6 +162,11 @@ impl<const LEN: usize> WString<LEN> {
154162
self.0.iter().position(|&b| b == 0).unwrap_or(self.0.len())
155163
}
156164

165+
/// Returns true if the string is empty.
166+
pub fn is_empty(&self) -> bool {
167+
self.len() == 0
168+
}
169+
157170
/// Get the slice up to the first null code unit.
158171
pub fn as_slice(&self) -> &[u16] {
159172
&self.0[..self.len()]
@@ -262,10 +275,13 @@ unsafe impl<const LEN: usize> zerocopy::AsBytes for WString<LEN> {
262275
fn only_derive_is_allowed_to_implement_this_trait() { }
263276
}
264277

265-
unsafe impl<const LEN: usize> zerocopy::FromBytes for WString<LEN> {
278+
unsafe impl<const LEN: usize> zerocopy::FromZeroes for WString<LEN> {
266279
fn only_derive_is_allowed_to_implement_this_trait() { }
267280
}
268281

282+
unsafe impl<const LEN: usize> zerocopy::FromBytes for WString<LEN> {
283+
fn only_derive_is_allowed_to_implement_this_trait() { }
284+
}
269285

270286
// compatibility aliases
271287

src/test/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use byteorder::{ByteOrder, ReadBytesExt, WriteBytesExt, LE};
1212
use once_cell::sync::Lazy;
1313
use zerocopy::{
1414
byteorder::{U32, U64},
15-
AsBytes, FromBytes,
15+
AsBytes, FromBytes, FromZeroes,
1616
};
1717

1818
use crate::client::{AddNotif, AdsHeader, IndexLength, IndexLengthRW};
@@ -448,7 +448,7 @@ impl Server {
448448
}
449449
}
450450

451-
#[derive(AsBytes, FromBytes, Debug, Default)]
451+
#[derive(AsBytes, FromBytes, FromZeroes, Debug, Default)]
452452
#[repr(C)]
453453
struct SingleNotification {
454454
len: U32<LE>,

src/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use std::{char, iter, str};
77

88
use byteorder::{ByteOrder, ReadBytesExt, WriteBytesExt, LE};
99
use zerocopy::byteorder::{U16, U32};
10-
use zerocopy::{AsBytes, FromBytes};
10+
use zerocopy::{AsBytes, FromBytes, FromZeroes};
1111

1212
use crate::errors::ErrContext;
1313
use crate::{AmsAddr, AmsNetId, Error, Result};
@@ -295,7 +295,7 @@ pub fn get_info(target: (&str, u16)) -> Result<SysInfo> {
295295
})
296296
}
297297

298-
#[derive(FromBytes, AsBytes, Default)]
298+
#[derive(FromBytes, FromZeroes, AsBytes, Default)]
299299
#[repr(C)]
300300
pub(crate) struct UdpHeader {
301301
magic: U32<LE>,

0 commit comments

Comments
 (0)