Skip to content

Commit

Permalink
export *Response
Browse files Browse the repository at this point in the history
  • Loading branch information
bouzuya committed Jun 28, 2021
1 parent ddec1ef commit 3e21ccf
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/client.rs
Expand Up @@ -4,7 +4,7 @@ mod response;

pub use self::config::Config;
pub use self::entry_params::EntryParams;
use self::response::{
pub use self::response::{
CreateEntryResponse, DeleteEntryResponse, GetEntryResponse, ListCategoriesResponse,
ListEntriesResponse, UpdateEntryResponse,
};
Expand Down
30 changes: 25 additions & 5 deletions src/client/response.rs
Expand Up @@ -8,6 +8,7 @@ use quick_xml::{
};
use reqwest::Url;
use std::convert::TryFrom;
use std::fmt::Display;
use std::str::FromStr;
use thiserror::Error;

Expand All @@ -18,11 +19,6 @@ pub type ListCategoriesResponse = CategoryDocumentResponse;
pub type ListEntriesResponse = CollectionResponse;
pub type UpdateEntryResponse = MemberResponse;

#[derive(Debug)]
pub struct Response {
body: String,
}

#[derive(Debug, Eq, Error, PartialEq)]
#[error("parse entry error")]
pub struct ParseEntry;
Expand Down Expand Up @@ -198,6 +194,12 @@ pub struct MemberResponse {
body: String,
}

impl Display for MemberResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.body)
}
}

impl From<String> for MemberResponse {
fn from(body: String) -> Self {
Self { body }
Expand All @@ -222,6 +224,12 @@ impl TryFrom<MemberResponse> for Entry {
#[derive(Debug, Eq, PartialEq)]
pub struct EmptyResponse;

impl Display for EmptyResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "")
}
}

impl From<String> for EmptyResponse {
fn from(_: String) -> Self {
Self
Expand All @@ -239,6 +247,12 @@ pub struct CategoryDocumentResponse {
body: String,
}

impl Display for CategoryDocumentResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.body)
}
}

impl From<String> for CategoryDocumentResponse {
fn from(body: String) -> Self {
Self { body }
Expand All @@ -264,6 +278,12 @@ pub struct CollectionResponse {
body: String,
}

impl Display for CollectionResponse {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self.body)
}
}

impl From<String> for CollectionResponse {
fn from(body: String) -> Self {
Self { body }
Expand Down
6 changes: 5 additions & 1 deletion src/lib.rs
Expand Up @@ -3,6 +3,10 @@ pub mod command;
mod entry;
mod entry_id;

pub use client::{Client, ClientError, Config, EntryParams, PartialList};
pub use client::{
Client, ClientError, Config, CreateEntryResponse, DeleteEntryResponse, EntryParams,
GetEntryResponse, ListCategoriesResponse, ListEntriesResponse, PartialList,
UpdateEntryResponse,
};
pub use entry::Entry;
pub use entry_id::EntryId;

0 comments on commit 3e21ccf

Please sign in to comment.