macro_rules! impl_from_cql_value_from_method { ($T:ty, $convert_func:ident) => { ... }; }
👎Deprecated since 0.15.1: Legacy deserialization API is inefficient and is going to be removed soon
Expand description
This macro implements FromCqlVal given a type and method of CqlValue that returns this type.
It can be useful in client code in case you have an extension trait for CqlValue
and you would like to convert one of its methods into a FromCqlVal impl.
The conversion method must return an Option<T>
. None
values will be
converted to CqlValue::BadCqlType
.
§Example
struct MyBytes(Vec<u8>);
trait CqlValueExt {
fn into_my_bytes(self) -> Option<MyBytes>;
}
impl CqlValueExt for CqlValue {
fn into_my_bytes(self) -> Option<MyBytes> {
Some(MyBytes(self.into_blob()?))
}
}
impl_from_cql_value_from_method!(MyBytes, into_my_bytes);