Commit 9dcb6054 authored by Éloïs's avatar Éloïs

[style] apply fmt

parent 8c7e3ce2
use dubp_documents::*;
use dubp_documents::v10::certification::*;
use dubp_documents::v10::identity::*;
use dubp_documents::v10::membership::*;
use dubp_documents::v10::certification::*;
use dubp_documents::v10::revocation::*;
use dubp_documents::v10::transaction::*;
use durs_network_documents::*;
use durs_network_documents::network_peer::PeerCardV11;
use dubp_documents::*;
use durs_network_documents::network_head_v3::NetworkHeadV3;
use durs_network_documents::network_peer::PeerCardV11;
use durs_network_documents::*;
use wasm_bindgen::prelude::*;
#[wasm_bindgen]
......@@ -26,40 +26,51 @@ pub enum DocumentType {
pub fn parse_doc_into_json(doc: &str, doc_type: DocumentType) -> String {
match doc_type {
DocumentType::All => match DUBPDocument::parse(doc) {
Ok(document) => serde_json::to_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Ok(document) => serde_json::to_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(_) => match NetworkDocument::parse(doc) {
Ok(document) => serde_json::to_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Err(_) => "Invalid document. Specify the expected document type for more information.".to_owned(),
}
}
Ok(document) => serde_json::to_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(_) => {
"Invalid document. Specify the expected document type for more information."
.to_owned()
}
},
},
DocumentType::TxV10 => match TransactionDocumentParser::parse(doc) {
Ok(document) => serde_json::to_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
}
Ok(document) => serde_json::to_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
},
DocumentType::IdentityV10 => match IdentityDocumentParser::parse(doc) {
Ok(document) => IdentityDocument::to_json_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
}
Ok(document) => IdentityDocument::to_json_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
},
DocumentType::MembershipV10 => match MembershipDocumentParser::parse(doc) {
Ok(document) => MembershipDocument::to_json_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
}
Ok(document) => MembershipDocument::to_json_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
},
DocumentType::CertificationV10 => match CertificationDocumentParser::parse(doc) {
Ok(document) => serde_json::to_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
}
Ok(document) => serde_json::to_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
},
DocumentType::RevocationV10 => match RevocationDocumentParser::parse(doc) {
Ok(document) => serde_json::to_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
}
Ok(document) => serde_json::to_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
},
DocumentType::PeerV11 => match PeerCardV11::parse_from_raw(doc) {
Ok(document) => serde_json::to_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
}
Ok(document) => serde_json::to_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
},
DocumentType::HeadV3 => match NetworkHeadV3::parse_from_raw(doc) {
Ok(document) => serde_json::to_string_pretty(&document).unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
}
//_ => "Error: invalid argument value : doc_type. It's a bug in the calling code, please open an issue on the front interface repository.".to_owned()
Ok(document) => serde_json::to_string_pretty(&document)
.unwrap_or("Fail to jsonifie document.".to_owned()),
Err(pest_error) => format!("{:?}", pest_error),
}, //_ => "Error: invalid argument value : doc_type. It's a bug in the calling code, please open an issue on the front interface repository.".to_owned()
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment