Skip to content

Commit 46a3fee

Browse files
committed
Run cargo fmt
Signed-off-by: Gris Ge <[email protected]>
1 parent 100413a commit 46a3fee

File tree

4 files changed

+41
-20
lines changed

4 files changed

+41
-20
lines changed

.rustfmt.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
max_width = 80
22
wrap_comments = true
33
reorder_imports = true
4+
format_strings = true
45
edition = "2021"

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
authors = ["Corentin Henry <[email protected]>"]
33
name = "netlink-packet-core"
44
version = "0.7.0"
5-
edition = "2018"
5+
edition = "2021"
66

77
homepage = "https://github.com/rust-netlink/netlink-packet-core"
88
keywords = ["netlink", "linux"]

src/done.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ impl<T: AsRef<[u8]>> DoneBuffer<T> {
3939
let len = self.buffer.as_ref().len();
4040
if len < DONE_HEADER_LEN {
4141
Err(format!(
42-
"invalid DoneBuffer: length is {len} but DoneBuffer are \
43-
at least {DONE_HEADER_LEN} bytes"
42+
"invalid DoneBuffer: length is {len} but DoneBuffer are at \
43+
least {DONE_HEADER_LEN} bytes"
4444
)
4545
.into())
4646
} else {

src/error.rs

Lines changed: 37 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -75,51 +75,71 @@ impl DecodeError {
7575
) -> Self {
7676
Self {
7777
msg: format!(
78-
"Invalid buffer {name}. \
79-
Expected at least {minimum_length} bytes, \
80-
received {received} bytes"
78+
"Invalid buffer {name}. Expected at least {minimum_length} \
79+
bytes, received {received} bytes"
8180
),
8281
}
8382
}
8483
pub fn invalid_mac_address(received: usize) -> Self {
85-
Self{
86-
msg: format!("Invalid MAC address. Expected 6 bytes, received {received} bytes"),
84+
Self {
85+
msg: format!(
86+
"Invalid MAC address. Expected 6 bytes, received {received} \
87+
bytes"
88+
),
8789
}
8890
}
8991

9092
pub fn invalid_ip_address(received: usize) -> Self {
91-
Self{
92-
msg: format!("Invalid IP address. Expected 4 or 16 bytes, received {received} bytes"),
93+
Self {
94+
msg: format!(
95+
"Invalid IP address. Expected 4 or 16 bytes, received \
96+
{received} bytes"
97+
),
9398
}
9499
}
95100

96101
pub fn invalid_number(expected: usize, received: usize) -> Self {
97-
Self{
98-
msg: format!("Invalid number. Expected {expected} bytes, received {received} bytes"),
102+
Self {
103+
msg: format!(
104+
"Invalid number. Expected {expected} bytes, received \
105+
{received} bytes"
106+
),
99107
}
100108
}
101109

102110
pub fn nla_buffer_too_small(buffer_len: usize, nla_len: usize) -> Self {
103-
Self{
104-
msg: format!("buffer has length {buffer_len}, but an NLA header is {nla_len} bytes"),
111+
Self {
112+
msg: format!(
113+
"buffer has length {buffer_len}, but an NLA header is \
114+
{nla_len} bytes"
115+
),
105116
}
106117
}
107118

108119
pub fn nla_length_mismatch(buffer_len: usize, nla_len: usize) -> Self {
109-
Self{
110-
msg: format!("buffer has length: {buffer_len}, but the NLA is {nla_len} bytes"),
120+
Self {
121+
msg: format!(
122+
"buffer has length: {buffer_len}, but the NLA is {nla_len} \
123+
bytes"
124+
),
111125
}
112126
}
113127

114128
pub fn nla_invalid_length(buffer_len: usize, nla_len: usize) -> Self {
115-
Self{
116-
msg: format!("NLA has invalid length: {nla_len} (should be at least {buffer_len} bytes)"),
129+
Self {
130+
msg: format!(
131+
"NLA has invalid length: {nla_len} (should be at least \
132+
{buffer_len} bytes)"
133+
),
117134
}
118135
}
119136

120137
pub fn buffer_too_small(buffer_len: usize, value_len: usize) -> Self {
121138
Self {
122-
msg: format!("Buffer too small: {buffer_len} (should be at least {value_len} bytes"),
139+
msg: format!(
140+
"Buffer too small: {buffer_len} (should be at least \
141+
{value_len} bytes"
142+
),
123143
}
124144
}
125145
}
@@ -154,7 +174,7 @@ impl<T: AsRef<[u8]>> ErrorBuffer<T> {
154174
Err(DecodeError {
155175
msg: format!(
156176
"invalid ErrorBuffer: length is {len} but ErrorBuffer are \
157-
at least {ERROR_HEADER_LEN} bytes"
177+
at least {ERROR_HEADER_LEN} bytes"
158178
),
159179
})
160180
} else {

0 commit comments

Comments
 (0)