serde_redis/into_cow.rs
1use redis::Value;
2use std::borrow::Cow;
3
4/// A value that can be turned into a `Cow<'a, Value>`. This is primarily useful
5/// because there is not an `impl Into<Cow<'a, Value>>` built-in for
6/// `redis::Value` and `&'a redis::Value`. This allows `from_redis_value` to take
7/// either one of those.
8pub trait IntoCow<'a> {
9 fn into_cow(self) -> Cow<'a, Value>;
10}
11
12impl<'a> IntoCow<'a> for &'a Value {
13 fn into_cow(self) -> Cow<'a, Value> {
14 Cow::Borrowed(self)
15 }
16}
17
18impl IntoCow<'static> for Value {
19 fn into_cow(self) -> Cow<'static, Value> {
20 Cow::Owned(self)
21 }
22}