convert is added
This commit is contained in:
parent
20d8e87d9f
commit
bb6c77004f
|
@ -1,6 +1,6 @@
|
|||
//!
|
||||
//!
|
||||
|
||||
use beteran_protobuf_rust as bpr;
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub enum Sort {
|
||||
|
@ -10,6 +10,30 @@ pub enum Sort {
|
|||
DESC(String),
|
||||
}
|
||||
|
||||
impl From<Sort> for bpr::protobuf::pagination::Sort {
|
||||
fn from(d: Sort) -> Self {
|
||||
match d {
|
||||
Sort::ASC(by) => bpr::protobuf::pagination::Sort {
|
||||
by,
|
||||
order: bpr::protobuf::pagination::SortOrder::Asc as i32,
|
||||
},
|
||||
Sort::DESC(by) => bpr::protobuf::pagination::Sort {
|
||||
by,
|
||||
order: bpr::protobuf::pagination::SortOrder::Desc as i32,
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bpr::protobuf::pagination::Sort> for Sort {
|
||||
fn from(d: bpr::protobuf::pagination::Sort) -> Self {
|
||||
match d.order {
|
||||
x if x == bpr::protobuf::pagination::SortOrder::Desc as i32 => Sort::DESC(d.by),
|
||||
_ => Sort::ASC(d.by),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
///
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Pagination {
|
||||
|
@ -18,3 +42,21 @@ pub struct Pagination {
|
|||
///
|
||||
pub page_size: Option<u32>,
|
||||
}
|
||||
|
||||
impl From<Pagination> for bpr::protobuf::pagination::Pagination {
|
||||
fn from(d: Pagination) -> Self {
|
||||
bpr::protobuf::pagination::Pagination {
|
||||
page: d.page,
|
||||
page_size: d.page_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl From<bpr::protobuf::pagination::Pagination> for Pagination {
|
||||
fn from(d: bpr::protobuf::pagination::Pagination) -> Self {
|
||||
Pagination {
|
||||
page: d.page,
|
||||
page_size: d.page_size,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user