remove anyhow error for in trait one

This commit is contained in:
Simon Wicky
2026-05-15 12:47:06 +02:00
parent f0ecdfd295
commit 53dec68378
11 changed files with 18 additions and 11 deletions
Generated
-1
View File
@@ -7489,7 +7489,6 @@ dependencies = [
name = "nym-lp-data"
version = "1.20.4"
dependencies = [
"anyhow",
"nym-lp",
"tracing",
]
-1
View File
@@ -13,7 +13,6 @@ documentation.workspace = true
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
anyhow.workspace = true
tracing.workspace = true
bytes.workspace = true
num_enum.workspace = true
+1 -1
View File
@@ -278,7 +278,7 @@ where
{
fn process_unwrapped(&mut self, payload: TimedPayload<Ts>, kind: Mk) -> Option<Vec<u8>>;
fn unwrap(&mut self, input: Pkt, timestamp: Ts) -> anyhow::Result<Option<Vec<u8>>> {
fn unwrap(&mut self, input: Pkt, timestamp: Ts) -> Result<Option<Vec<u8>>, Self::Error> {
Ok(self
.wire_unwrap(input, timestamp)?
.and_then(|(payload, kind)| self.process_unwrapped(payload, kind)))
+2 -1
View File
@@ -82,7 +82,8 @@ where
Pkt: Into<Vec<u8>>,
{
type Frame = Vec<u8>;
fn packet_to_frame(&self, packet: Pkt, timestamp: Ts) -> anyhow::Result<TimedPayload<Ts>> {
type Error = std::convert::Infallible;
fn packet_to_frame(&self, packet: Pkt, timestamp: Ts) -> Result<TimedPayload<Ts>, Self::Error> {
Ok(TimedData {
timestamp,
data: packet.into(),
+4 -2
View File
@@ -77,17 +77,19 @@ pub trait Transport<Ts, Pkt, NdId> {
///
/// # Associated Types
/// - `Frame`: Frame type produced as output.
/// - `Error`: Error type
///
/// # Required Methods
/// - `packet_to_frame`: Strips the transport layer from a packet, returning the inner frame
/// tagged with the given timestamp.
pub trait TransportUnwrap<Ts, Pkt> {
type Frame;
type Error;
fn packet_to_frame(
&self,
packet: Pkt,
timestamp: Ts,
) -> anyhow::Result<TimedData<Ts, Self::Frame>>;
) -> Result<TimedData<Ts, Self::Frame>, Self::Error>;
}
/// Supertrait combining [`Framing`] and [`Transport`] into a reusable wire-wrapping layer.
@@ -160,7 +162,7 @@ where
&mut self,
input: Pkt,
timestamp: Ts,
) -> anyhow::Result<Option<(TimedPayload<Ts>, Mk)>> {
) -> Result<Option<(TimedPayload<Ts>, Mk)>, Self::Error> {
let frame = self.packet_to_frame(input, timestamp)?;
Ok(self.frame_to_message(frame))
}
+1 -1
View File
@@ -44,7 +44,7 @@ where
&mut self,
input: TimedData<Ts, Pkt>,
timestamp: Ts,
) -> anyhow::Result<Vec<AddressedTimedData<Ts, Pkt, NdId>>> {
) -> Result<Vec<AddressedTimedData<Ts, Pkt, NdId>>, Self::Error> {
let TimedData {
data: packet,
timestamp: ts,
+1
View File
@@ -228,6 +228,7 @@ impl<Ts> FramingUnwrap<Ts, SimpleMessage> for SimpleClientUnwrapping {
// Delegation to SimpleWireUnwrapper
impl<Ts: Clone> TransportUnwrap<Ts, SimplePacket> for SimpleClientUnwrapping {
type Frame = SimpleFrame;
type Error = anyhow::Error;
fn packet_to_frame(
&self,
packet: SimplePacket,
+1 -1
View File
@@ -143,7 +143,7 @@ impl<Ts: Clone + GenerateDelay + PartialOrd + Send, R: Rng + Send>
}
fn unwrap(&mut self, input: Vec<u8>, timestamp: Ts) -> anyhow::Result<Option<Vec<u8>>> {
self.unwrapper.unwrap(input, timestamp)
Ok(self.unwrapper.unwrap(input, timestamp)?)
}
}
+1
View File
@@ -146,6 +146,7 @@ impl<Ts> FramingUnwrap<Ts, SimpleMessage> for SimpleProcessingNode {
impl<Ts: Clone> TransportUnwrap<Ts, SimplePacket> for SimpleProcessingNode {
type Frame = SimpleFrame;
type Error = anyhow::Error;
fn packet_to_frame(
&self,
packet: SimplePacket,
+6 -3
View File
@@ -60,9 +60,12 @@ where
input: TimedData<Ts, SimMixPacket>,
timestamp: Ts,
) -> anyhow::Result<Vec<AddressedTimedData<Ts, SimMixPacket, NodeId>>> {
MixnodeProcessingPipeline::<Ts, SimMixPacket, SphinxMessage, NodeId>::process(
self, input, timestamp,
)
Ok(MixnodeProcessingPipeline::<
Ts,
SimMixPacket,
SphinxMessage,
NodeId,
>::process(self, input, timestamp)?)
}
}
+1
View File
@@ -262,6 +262,7 @@ impl<Ts> FramingUnwrap<Ts, SimpleMessage> for SimpleWireUnwrapper {
impl<Ts: Clone> TransportUnwrap<Ts, SimplePacket> for SimpleWireUnwrapper {
type Frame = SimpleFrame;
type Error = anyhow::Error;
fn packet_to_frame(
&self,
packet: SimplePacket,