Skip to content

Instantly share code, notes, and snippets.

View yaymukund's full-sized avatar
🍅
tomato tomato

mukund yaymukund

🍅
tomato tomato
View GitHub Profile
use super::downloader::HttpClient;
use hyper;
use hyper::rt::{Future, Stream};
use std::error::Error;
use std::io::{Error as IOError, Read};
use std::sync::{atomic, mpsc, Arc};
pub struct Download {
uri: String,
body: mpsc::Receiver<hyper::Chunk>,
use super::downloader::HttpClient;
use hyper;
use hyper::rt::{Future, Stream};
use std::error::Error;
use std::io::{Error as IOError, Read};
use std::sync::{atomic, mpsc, Arc};
pub struct Download {
uri: String,
body: mpsc::Receiver<hyper::Chunk>,
use super::downloader::HttpClient;
use futures::future;
use futures::sink::Sink;
use futures::sync::mpsc;
use hyper::rt::{Future, Stream};
use hyper::{Chunk, Uri};
use std::sync::{atomic, Arc};
pub struct Download {
uri: String,
use super::downloader::HttpClient;
use futures::sink::Sink;
use futures::sync::mpsc;
use hyper::rt::{Future, Stream};
use hyper::{Chunk, Uri};
use std::sync::{atomic, Arc};
pub struct Download {
uri: String,
body: Option<mpsc::Receiver<Chunk>>,
use super::downloader::HttpClient;
use hyper::rt::{Future, Stream};
use hyper::Uri;
use std::sync::{Arc, Mutex};
pub struct Download {
uri: String,
data: Arc<Mutex<Vec<u8>>>,
}
use super::download::Download;
use hyper::client::HttpConnector;
use hyper::rt::Future;
use hyper::{Body, Client};
use hyper_tls::HttpsConnector;
use native_tls::TlsConnector;
use tokio::runtime::Runtime;
pub type HttpClient = Client<HttpsConnector<HttpConnector>>;
use super::downloader::HttpClient;
use hyper::rt::{Future, Stream};
use hyper::Uri;
use std::sync::Arc;
pub struct Download {
uri: String,
data: Arc<Vec<u8>>,
}
use super::downloader::HttpClient;
use hyper::client::ResponseFuture;
use hyper::rt::Future;
use hyper::Uri;
enum DownloadStatus {
Idle,
PendingResponse,
PendingBody,
Completed,
@yaymukund
yaymukund / help.md
Last active August 25, 2018 16:53
help!
  1. Is there some way to use HttpClient in Downloader without making it public?
  2. Is super::... the right way to do this?
// downloader/downloader.rs
use super::http_client::HttpClient;
pub struct Downloader {
    client: HttpClient;
}
use hyper::client::ResponseFuture;
use hyper::{Body, Response};
use tokio::prelude::IntoFuture;
struct Download {
future: ResponseFuture,
}
impl Download {
pub fn new(future: ResponseFuture) -> Download {