pub struct TransferCrc { /* private fields */ }
Expand description
Calculates the 32-bit transfer CRC
Creates a new CRC calculation
15
16
17
18
19
20
21
22
23
24
fn main() -> Result<(), Box<dyn Error>> {
let mut crc = TransferCrc::new();
for byte in env::args().skip(1).map(|arg| u8::from_str_radix(&arg, 16)) {
let byte = byte?;
crc.add(byte);
}
println!("{:#06x}", crc.get());
Ok(())
}
Adds a byte to the CRC calculation
15
16
17
18
19
20
21
22
23
24
fn main() -> Result<(), Box<dyn Error>> {
let mut crc = TransferCrc::new();
for byte in env::args().skip(1).map(|arg| u8::from_str_radix(&arg, 16)) {
let byte = byte?;
crc.add(byte);
}
println!("{:#06x}", crc.get());
Ok(())
}
Adds all the bytes in a slice to the CRC calculation
Returns the CRC calculated over the bytes added through previous calls
15
16
17
18
19
20
21
22
23
24
fn main() -> Result<(), Box<dyn Error>> {
let mut crc = TransferCrc::new();
for byte in env::args().skip(1).map(|arg| u8::from_str_radix(&arg, 16)) {
let byte = byte?;
crc.add(byte);
}
println!("{:#06x}", crc.get());
Ok(())
}
Returns the “default value” for a type.
Read more
Immutably borrows from an owned value.
Read more
Mutably borrows from an owned value.
Read more
Returns the argument unchanged.
Calls U::from(self)
.
That is, this conversion is whatever the implementation of
From<T> for U
chooses to do.
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.