diff options
| author | Max Audron <audron@cocaine.farm> | 2025-02-22 22:59:01 +0100 |
|---|---|---|
| committer | Max Audron <audron@cocaine.farm> | 2025-02-22 22:59:01 +0100 |
| commit | b8ad94cd5061445a45d0790eee36014d34ad6817 (patch) | |
| tree | fb7d11e136b968d2f2b3593ba9163894baed8912 /src/primitive/variant.rs | |
| parent | update dependencies and fix errors (diff) | |
replace deprecated failure crate with thiserror
this changes the public API in that all our methods now return a proper
ProtocolError crate. Needed change anyways to properly deal with all our
errors in the long run.
Will still need to do a pass through the crate to remove all existing
unwraps where it makes sense.
Diffstat (limited to 'src/primitive/variant.rs')
| -rw-r--r-- | src/primitive/variant.rs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/primitive/variant.rs b/src/primitive/variant.rs index 46334a0..e84e5c0 100644 --- a/src/primitive/variant.rs +++ b/src/primitive/variant.rs @@ -1,7 +1,5 @@ use std::{collections::HashMap, vec::Vec}; -use failure::Error; - use itertools::Itertools; use log::{error, trace}; @@ -155,13 +153,13 @@ where } impl Serialize for Variant { - fn serialize(&self) -> Result<Vec<u8>, Error> { + fn serialize(&self) -> Result<Vec<u8>, ProtocolError> { let unknown: u8 = 0x00; let mut res: Vec<u8> = Vec::new(); match self { Variant::Unknown => { - bail!(ProtocolError::UnknownVariant); + return Err(ProtocolError::UnknownVariant); } Variant::VariantMap(v) => { res.extend(primitive::QVARIANTMAP.to_be_bytes().iter()); @@ -277,7 +275,7 @@ impl Serialize for Variant { } impl Deserialize for Variant { - fn parse(b: &[u8]) -> Result<(usize, Self), Error> { + fn parse(b: &[u8]) -> Result<(usize, Self), ProtocolError> { trace!("trying to parse variant with bytes: {:?}", b); let (_, qtype) = i32::parse(&b[0..4])?; let qtype = qtype as u32; @@ -426,7 +424,7 @@ impl Deserialize for Variant { } err => { error!(target: "parser", "UnknownVariant: {:x?}", err); - bail!(ProtocolError::UnknownVariant); + return Err(ProtocolError::UnknownVariant); } } } |
