refactor: Update public key column type from String
to PublicKey
#29
1 changed files with 5 additions and 9 deletions
|
@ -44,24 +44,20 @@ impl From<PublicKey> for Value {
|
|||
|
||||
impl TryGetable for PublicKey {
|
||||
fn try_get_by<I: sea_orm::ColIdx>(res: &QueryResult, idx: I) -> Result<Self, TryGetError> {
|
||||
<String as TryGetable>::try_get_by(res, idx)
|
||||
.map(|v| {
|
||||
PublicKey::from_str(&v)
|
||||
.map_err(|err| TryGetError::DbErr(DbErr::Type(err.to_string())))
|
||||
})
|
||||
.and_then(|res| res)
|
||||
<String as TryGetable>::try_get_by(res, idx).and_then(|v| {
|
||||
PublicKey::from_str(&v).map_err(|err| TryGetError::DbErr(DbErr::Type(err.to_string())))
|
||||
awiteb marked this conversation as resolved
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl ValueType for PublicKey {
|
||||
fn try_from(v: Value) -> Result<Self, ValueTypeErr> {
|
||||
<String as ValueType>::try_from(v)
|
||||
.map(|v| PublicKey::from_str(&v).map_err(|_| ValueTypeErr))
|
||||
.and_then(|res| res)
|
||||
.and_then(|v| PublicKey::from_str(&v).map_err(|_| ValueTypeErr))
|
||||
}
|
||||
|
||||
fn type_name() -> String {
|
||||
awiteb marked this conversation as resolved
Amjad50
commented
same as above, same as above, `and_then` instead of `map`
|
||||
stringify!(PublicKey).to_owned()
|
||||
String::from("PublicKey")
|
||||
}
|
||||
|
||||
fn array_type() -> ArrayType {
|
||||
|
|
Loading…
Reference in a new issue
replace
map
byand_then
and you won't needand_then(|res| res)