mirror of
https://github.com/AppFlowy-IO/AppFlowy.git
synced 2025-10-19 20:11:33 +00:00
37 lines
839 B
Rust
37 lines
839 B
Rust
use crate::{entities::doc::parser::DocId, errors::*};
|
|
use flowy_derive::ProtoBuf;
|
|
use std::convert::TryInto;
|
|
|
|
#[derive(Default, ProtoBuf)]
|
|
pub struct QueryDocRequest {
|
|
#[pb(index = 1)]
|
|
pub doc_id: String,
|
|
|
|
#[pb(index = 2)]
|
|
pub read_content: bool,
|
|
}
|
|
|
|
pub struct QueryDocParams {
|
|
pub doc_id: String,
|
|
pub read_content: bool,
|
|
}
|
|
|
|
impl TryInto<QueryDocParams> for QueryDocRequest {
|
|
type Error = EditorError;
|
|
|
|
fn try_into(self) -> Result<QueryDocParams, Self::Error> {
|
|
let doc_id = DocId::parse(self.doc_id)
|
|
.map_err(|e| {
|
|
ErrorBuilder::new(EditorErrorCode::DocViewIdInvalid)
|
|
.msg(e)
|
|
.build()
|
|
})?
|
|
.0;
|
|
|
|
Ok(QueryDocParams {
|
|
doc_id,
|
|
read_content: self.read_content,
|
|
})
|
|
}
|
|
}
|