-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #37 from KodrAus/feat/index-response
Refactor Parsing
- Loading branch information
Showing
24 changed files
with
611 additions
and
421 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
use parsing::{IsOk, HttpResponseHead, ResponseBody, Unbuffered, MaybeOkResponse}; | ||
use error::*; | ||
|
||
/// A standard command acknowledgement response. | ||
#[derive(Deserialize, Debug, Clone)] | ||
pub struct CommandResponse { | ||
pub acknowledged: bool | ||
} | ||
|
||
impl IsOk for CommandResponse { | ||
fn is_ok<B: ResponseBody>(head: HttpResponseHead, body: Unbuffered<B>) -> Result<MaybeOkResponse<B>, ParseResponseError> { | ||
match head.status() { | ||
200...299 => Ok(MaybeOkResponse::ok(body)), | ||
_ => Ok(MaybeOkResponse::err(body)), | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
use common::Shards; | ||
use parsing::{IsOk, HttpResponseHead, ResponseBody, Unbuffered, MaybeOkResponse}; | ||
use error::*; | ||
|
||
/// Response for an [index document request](https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html). | ||
#[derive(Deserialize, Debug)] | ||
pub struct IndexResponse { | ||
#[serde(rename = "_index")] | ||
pub index: String, | ||
#[serde(rename = "_type")] | ||
pub ty: String, | ||
#[serde(rename = "_id")] | ||
pub id: String, | ||
#[serde(rename = "_version")] | ||
pub version: Option<u32>, | ||
pub created: bool, | ||
#[serde(rename = "_shards")] | ||
pub shards: Shards, | ||
} | ||
|
||
impl IsOk for IndexResponse { | ||
fn is_ok<B: ResponseBody>(head: HttpResponseHead, body: Unbuffered<B>) -> Result<MaybeOkResponse<B>, ParseResponseError> { | ||
match head.status() { | ||
200...299 => Ok(MaybeOkResponse::ok(body)), | ||
_ => Ok(MaybeOkResponse::err(body)), | ||
} | ||
} | ||
} |
Oops, something went wrong.