IMO it makes more sense to return Self::Error<'static> here because I think the default use case of this method is "I don't care about allocation, just gimme 'static". This would require to add the bound Self::Error<'a>: IntoBoundedStatic<Static = Self::Error<'static>>. This should be possible because as far as I know all actual error types derive ToStatic.
Alternatives:
The caller could convert the error to 'static at caller side
We could provide another method decode_static_static
Remove decode_static and force the user to always convert both message and error to 'static themselves
Good catch! Yeah, I think it should be Error<'static>. Alternative 4: Error could also be owned. In the end, it's only the tag that introduces the lifetime?
This is the current signature of Decoder::decode_static:
IMO it makes more sense to return
Self::Error<'static>
here because I think the default use case of this method is "I don't care about allocation, just gimme 'static". This would require to add the boundSelf::Error<'a>: IntoBoundedStatic<Static = Self::Error<'static>>
. This should be possible because as far as I know all actual error types deriveToStatic
.Alternatives:
'static
at caller sidedecode_static_static
decode_static
and force the user to always convert both message and error to'static
themselves