Hmm maybe it’s an issue with my exact setup. Here’s an un-simplified copy+paste of the actual traits. Maybe I missed some subtle detail in that simplification.
Crate packet
:
use zerocopy::{ByteSlice, ByteSliceMut};
pub trait BufferView { ... }
pub struct ParseMetadata { ... }
pub trait ParsablePacket<B: ByteSlice, ParseArgs>: Sized {
type Error;
fn parse<BV: BufferView<B>>(buffer: BV, args: ParseArgs) -> Result<Self, Self::Error>;
fn parse_mut<BV: BufferViewMut<B>>(buffer: BV, args: ParseArgs) -> Result<Self, Self::Error>
where
B: ByteSliceMut,
{ ... }
fn header_len(&self) -> usize;
fn body_len(&self) -> usize;
fn footer_len(&self) -> usize;
fn parse_metadata(&self) -> ParseMetadata { ... }
}
pub trait ParsableInnerPacket<B: ByteSlice, ParseArgs>: Sized {
type Error;
fn parse<BV: BufferView<B>>(buffer: BV, args: ParseArgs) -> Result<(Self, BV), Self::Error>;
fn parse_mut<BV: BufferView<B>>(buffer: BV, args: ParseArgs) -> Result<(Self, BV), Self::Error>
where
B: ByteSliceMut,
{ ... }
fn len(&self) -> usize;
}
impl<B: ByteSlice, ParseArgs, P: ParsableInnerPacket<B, ParseArgs>> ParsablePacket<B, ParseArgs>
for P
{
type Error = P::Error;
fn parse<BV: BufferView<B>>(buffer: BV, args: ParseArgs) -> Result<Self, Self::Error> { ... }
fn header_len(&self) -> usize { ... }
fn body_len(&self) -> usize { ... }
fn footer_len(&self) -> usize { ... }
}
Then, crate recovery_netstack_core
:
use zerocopy::ByteSlice;
use packet::ParsablePacket;
pub struct EthernetFrame<B> { ... }
impl<B: ByteSlice> ParsablePacket<B, ()> for EthernetFrame<B> {
type Error = ParseError;
fn header_len(&self) -> usize { ... }
fn body_len(&self) -> usize { ... }
fn footer_len(&self) -> usize { ... }
fn parse<BV: BufferView<B>>(mut buffer: BV, args: ()) -> Result<Self, ParseError> { ... }
}
The error:
error[E0119]: conflicting implementations of trait `packet::ParsablePacket<_, ()>` for type `wire::ethernet::EthernetFrame<_>`:
--> core/src/wire/ethernet.rs:60:1
|
60 | impl<B: ByteSlice> ParsablePacket<B, ()> for EthernetFrame<B> {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: conflicting implementation in crate `packet`:
- impl<B, ParseArgs, P> packet::ParsablePacket<B, ParseArgs> for P
where B: zerocopy::ByteSlice, P: packet::ParsableInnerPacket<B, ParseArgs>;
= note: downstream crates may implement trait `packet::ParsableInnerPacket<_, ()>` for type `wire::ethernet::EthernetFrame<_>`