Skip to content

Commit

Permalink
address SBs comments + add few TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
quettabit committed Feb 14, 2022
1 parent ad813e3 commit 4eb2452
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub enum Error {
TooLongExpiration { requested: u64, max: u64 },
#[error("Failed to parse url")]
UrlParse(#[source] url::ParseError),
#[error("Unable to stringize header value '{0:?}'")]
#[error("Unable to stringize or parse header value '{0:?}'")]
OpaqueHeaderValue(http::header::HeaderValue),
#[error("I/O error occurred")]
Io(#[source] IoError),
Expand Down
3 changes: 1 addition & 2 deletions src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,8 @@ where
if status.is_success() || status == StatusCode::from_u16(308).unwrap() {
Self::try_from(resp)
} else {
// If we get an error, but with a JSON payload, attempt to deserialize
// If we get an error, but with a JSON or plain text payload, attempt to deserialize
// an ApiError from it, otherwise fallback to the simple HttpStatus
// TODO: update ^ desc
if let Some(ct) = resp
.headers()
.get(http::header::CONTENT_TYPE)
Expand Down
29 changes: 15 additions & 14 deletions src/v1/objects/insert.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,17 @@ pub struct InsertResponse {
pub metadata: super::Metadata,
}

// TODO: add doc comment
pub struct InitResumableInsertResponse {
pub session_uri: String,
}

// TODO: add doc comment
pub enum ResumableInsertResponseMetadata {
PartialSize(u64),
Complete(Box<super::Metadata>),
}

// TODO: rethink abt fields' data types
pub struct ResumableInsertResponse {
pub metadata: ResumableInsertResponseMetadata,
}
Expand Down Expand Up @@ -124,20 +125,18 @@ where
if response.status() == StatusCode::from_u16(308).unwrap() {
let (parts, _body) = response.into_parts();
let end_pos = match parts.headers.get(http::header::RANGE) {
Some(range) => match range.to_str() {
Ok(range) => {
match range.split('-').last() {
Some(pos) => {
let pos = pos.parse::<u64>();
match pos {
Ok(pos) => Ok(pos),
Err(_err) => Err(Error::UnknownHeader(http::header::RANGE)), // TODO: better this
}
Some(range_val) => match range_val.to_str() {
Ok(range) => match range.split('-').last() {
Some(pos) => {
let pos = pos.parse::<u64>();
match pos {
Ok(pos) => Ok(pos),
Err(_err) => Err(Error::OpaqueHeaderValue(range_val.clone())),
}
None => Err(Error::UnknownHeader(http::header::RANGE)),
}
}
Err(_err) => Err(Error::OpaqueHeaderValue(range.clone())),
None => Err(Error::UnknownHeader(http::header::RANGE)),
},
Err(_err) => Err(Error::OpaqueHeaderValue(range_val.clone())),
},
None => Err(Error::UnknownHeader(http::header::RANGE)),
}?;
Expand Down Expand Up @@ -511,7 +510,8 @@ impl super::Object {
Ok(req_builder.method("POST").uri(uri).body(multipart)?)
}

pub fn initiate_resumable_insert<'a, OID>(
// TODO: add doc comment
pub fn init_resumable_insert<'a, OID>(
id: &OID,
content_type: Option<&str>,
) -> Result<http::Request<()>, Error>
Expand All @@ -537,6 +537,7 @@ impl super::Object {
Ok(req_builder.method("POST").uri(uri).body(())?)
}

// TODO: add doc comment
pub fn resumable_insert<B>(
session_uri: String,
content: B,
Expand Down

0 comments on commit 4eb2452

Please sign in to comment.