feat(mbuild): resumable-upload infrastructure

Layout the `ResumableUploadHelper` and implement the entire logic
with the mbuild renerator.

All that's left to be done is to implement the 'chunked upload' method.

The borrow checker helped me to prevent a bug as well.
This commit is contained in:
Sebastian Thiel
2015-03-21 13:55:15 +01:00
parent 98f4bbab47
commit 307d3f487c
5 changed files with 755 additions and 351 deletions

View File

@@ -290,4 +290,30 @@ impl<'a> Read for MultiPartReader<'a> {
}
}
}
}
/// The `X-Upload-Content-Type` header.
#[derive(Clone, PartialEq, Debug)]
pub struct XUploadContentType(pub Mime);
impl_header!(XUploadContentType,
"X-Upload-Content-Type",
Mime);
/// A utility type to perform a resumable upload from start to end.
pub struct ResumableUploadHelper<'a, NC: 'a> {
pub client: &'a mut hyper::client::Client<NC>,
pub delegate: &'a mut Delegate,
pub url: &'a str,
pub reader: &'a mut ReadSeek,
pub media_type: Mime,
pub content_size: u64
}
impl<'a, NC> ResumableUploadHelper<'a, NC>
where NC: hyper::net::NetworkConnector {
pub fn upload(&'a mut self) -> hyper::HttpResult<hyper::client::Response> {
Err(hyper::error::HttpError::HttpStatusError)
}
}