Improvements from clippy
This commit is contained in:
+1
-1
@@ -18,7 +18,7 @@ fn main() -> std::io::Result<()> {
|
|||||||
|
|
||||||
request.write_to_stream(&mut stream)?;
|
request.write_to_stream(&mut stream)?;
|
||||||
let response = read_string(&mut stream)?;
|
let response = read_string(&mut stream)?;
|
||||||
println!("Response: {}", response);
|
println!("Response: {response}");
|
||||||
|
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-3
@@ -1,4 +1,4 @@
|
|||||||
use std::io::{Error, ErrorKind, Read, Write};
|
use std::io::{Error, Read, Write};
|
||||||
|
|
||||||
/// The saslauthd protocol transmits strings as
|
/// The saslauthd protocol transmits strings as
|
||||||
/// 16-bit unsigned network-byte-order lengths followed
|
/// 16-bit unsigned network-byte-order lengths followed
|
||||||
@@ -16,7 +16,7 @@ pub fn read_string(stream: &mut impl Read) -> Result<String, Error> {
|
|||||||
|
|
||||||
match String::from_utf8(string_buffer) {
|
match String::from_utf8(string_buffer) {
|
||||||
Ok(str) => Ok(str),
|
Ok(str) => Ok(str),
|
||||||
Err(_err) => Err(Error::new(ErrorKind::Other, "Invalid UTF-8 sent")),
|
Err(_err) => Err(Error::other("Invalid UTF-8 sent")),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +24,7 @@ pub fn write_string(stream: &mut impl Write, s: &str) -> Result<(), Error> {
|
|||||||
let length = s.len();
|
let length = s.len();
|
||||||
|
|
||||||
if length > 0xffff {
|
if length > 0xffff {
|
||||||
return Err(Error::new(ErrorKind::Other, "String too long to write"));
|
return Err(Error::other("String too long to write"));
|
||||||
}
|
}
|
||||||
|
|
||||||
let length_buffer = [(length >> 8) as u8, (length & 0xff) as u8];
|
let length_buffer = [(length >> 8) as u8, (length & 0xff) as u8];
|
||||||
|
|||||||
Reference in New Issue
Block a user