Given your usage, I doubt you will manage to actually implement what you want with a PhantomData:
you want the returned Self::Item to be borrowing from something, most probably from Self (or it could be borrowing from BytesMut instead).
This gives:
pub
trait Decoder<'a> /* <- put the parameter here */ {
type Item; // may depend on `'a`
fn decode (
self: &'a mut Self, // 'a is the lifetime of a borrow of Self
src: &'_ mut BytesMut,
) -> Result<
Option<Self::Item>,
Self::Error,
>;
}
or if the borrow comes from BytesMut:
pub
trait Decoder<'a> /* <- put the parameter here */ {
type Item; // may depend on `'a`
fn decode (
self: &'_ mut Self,
src: &'a mut BytesMut, // 'a is the lifetime of a borrow of BytesMut
) -> Result<
Option<Self::Item>,
Self::Error,
>;
}
In which case I recommend renaming 'a for readability:
pub
trait Decoder<'bytes_mut> /* <- put the parameter here */ {
type Item; // may depend on `'bytes_mut`
fn decode (
self: &'_ mut Self,
src: &'bytes_mut mut BytesMut, // 'a is the lifetime of a borrow of BytesMut
) -> Result<
Option<Self::Item>,
Self::Error,
>;
}