Closed dracarys18 closed 1 week ago
I can take this up we need a different TryInto
implementation for Vec<u8>
and Vec<T>
where T is not u8
Hi @dracarys18,
Unfortunately I'm not sure how to do this on stable rust at the moment without specialization, but feel free to submit a PR if you can make it work.
After looking at this a bit more - If I'm reading this correctly it looks like TryFrom<T>
creates a From<T>
fallback automatically, and since From<u8>
already exists we can't implement both TryFrom<Vec<u8>> for RedisValue
and TryFrom<Vec<T>> for RedisValue
.
I think there's a few ways to work around this, but they have some downsides:
Vec<RedisValue::Integer>
and back to bytes (safe but expensive)From<u8> for RedisValue
impl (breaking)mem::transmute
(unsafe, and probably not useful since it would have to be used with TypeId::of(), which requires T: 'static, which is breaking)TryFrom
to do these type conversions so we can detect Vec<u8>
in the same manner that FromRedis
uses (breaking)For the next major version I'll probably remove the From<u8> for RedisValue
since Vec<u8>
is likely much more common, but for now I want to avoid any breaking changes.
@aembke I like the idea of last point can we make a feature flag for this so it wont break for others and slowly release it in the next release
Sounds good. In 9.4.0 there a new FF specialize-into-bytes
that will disable From<u8> for RedisValue
and enable TryFrom<Vec<u8>> for RedisValue
such that it uses RedisValue::Bytes
.
Oh that's awesome! Thanks @aembke
Fred version - 9.2.1 Redis version - 7.0.1 Platform - mac Deployment type - cluster|sentinel|centralized
Describe the bug For the following example below, Fred throws and error
value: Redis Error - kind: InvalidArgument, details: Invalid argument type: Array
while it's a valid type.To Reproduce Steps to reproduce the behavior:
hsetnx
function withVec<u8>
as value type.Logs (If possible set
RUST_LOG=fred=trace
and run with--features debug-ids
)Redis Error - kind: InvalidArgument, details: Invalid argument type: Array