[][src]Trait pikmin::downloader::Downloader

pub trait Downloader {
    type IDT: FromStr + Display;
    type ID: DownloaderID<Self::IDT> + From<Self::IDT>;
    type RAW;
    fn start_id(&self) -> Self::IDT;
fn end_id(&self) -> Self::IDT;
fn continue_condition(&self, current: &Self::IDT, end: &Self::IDT) -> bool;
fn fetch(&self, c: &Self::IDT) -> Result<Vec<Self::RAW>>;
fn convert(&self, v: &Self::RAW) -> Result<Trade>;
fn output(
        &self,
        u: Vec<Trade>,
        writer: &mut impl Writer
    ) -> Result<Self::IDT>;
fn sleep_millis(&self) -> u64; fn init_id(
        &self,
        default: Self::IDT,
        process_log_path: &Path
    ) -> Result<Self::IDT> { ... }
fn record_progress(&self, path: &Path, id: &str) -> Result<()> { ... }
fn run(
        &self,
        writer: &mut impl Writer,
        process_log_path: &Path
    ) -> Result<()> { ... } }

An abstraction of downloaders. You can make a new downloader by implementing this trait.

Associated Types

type IDT: FromStr + Display

A type of element which ID is made up of.

type ID: DownloaderID<Self::IDT> + From<Self::IDT>

A type of ID for specifying the downloading point in an API client.

type RAW

A type of downloaded trade data.

Loading content...

Required methods

fn start_id(&self) -> Self::IDT

Returns beginning ID for a downloading process.

fn end_id(&self) -> Self::IDT

Returns ending ID for a downloading process.

fn continue_condition(&self, current: &Self::IDT, end: &Self::IDT) -> bool

Judges whether to continue downloading or not.

fn fetch(&self, c: &Self::IDT) -> Result<Vec<Self::RAW>>

Fetches trade data from somewhere (typically API).

fn convert(&self, v: &Self::RAW) -> Result<Trade>

Converts a raw trade datum into a standard trade struct.

fn output(
    &self,
    u: Vec<Trade>,
    writer: &mut impl Writer
) -> Result<Self::IDT>

Writes trade data to somewhere with a given writer. This must return an id for the next iteration, and this will be recorded on a progress file.

fn sleep_millis(&self) -> u64

Returns milli seconds to sleep between fetching processes.

Loading content...

Provided methods

fn init_id(
    &self,
    default: Self::IDT,
    process_log_path: &Path
) -> Result<Self::IDT>

Returns initial ID from a progress file. If reading is failed, use a given default value.

fn record_progress(&self, path: &Path, id: &str) -> Result<()>

Records progress on somewhere (typically a file).

fn run(
    &self,
    writer: &mut impl Writer,
    process_log_path: &Path
) -> Result<()>

Executes downloading.

Loading content...

Implementors

impl Downloader for BfDownloader[src]

type IDT = u64

type ID = OrdID<Self::IDT>

type RAW = BfGetExecution

fn init_id(
    &self,
    default: Self::IDT,
    process_log_path: &Path
) -> Result<Self::IDT>
[src]

fn record_progress(&self, path: &Path, id: &str) -> Result<()>[src]

fn run(
    &self,
    writer: &mut impl Writer,
    process_log_path: &Path
) -> Result<()>
[src]

impl Downloader for MexDownloader[src]

type IDT = DateTime<Utc>

type ID = DateTimeID

type RAW = MexGetExecution

fn output(
    &self,
    u: Vec<Trade>,
    writer: &mut impl Writer
) -> Result<Self::IDT>
[src]

Possibly some trades will be cut from the response if we just increment the starting timestamp since the API will return just 1,000 trades for single request. In order to avoid this, the last trades in terms of the traded timestamp should be ignored at the first time, and request again from the timestamp.

Errors

In order to avoid an infinite loop, this function will return an error when there are more than 1,000 executions at the same timestamp.

fn sleep_millis(&self) -> u64[src]

if we login, the API limit becomes 300/5min if not, it's 150/5min

fn init_id(
    &self,
    default: Self::IDT,
    process_log_path: &Path
) -> Result<Self::IDT>
[src]

fn record_progress(&self, path: &Path, id: &str) -> Result<()>[src]

fn run(
    &self,
    writer: &mut impl Writer,
    process_log_path: &Path
) -> Result<()>
[src]

impl Downloader for LiquidDownloader[src]

type IDT = DateTime<Utc>

type ID = DateTimeID

type RAW = QnGetExecution

fn output(
    &self,
    u: Vec<Trade>,
    writer: &mut impl Writer
) -> Result<Self::IDT>
[src]

Liquid (by Quoine) API has inconsistent statements in the document (https://developers.quoine.com/#get-executions-by-timestamp). As Get Executions by Timestamp won't return the complete executions at the same timestamp, this function has to re-request the executions for the timestamp so as to obtain all of them.

Errors

In order to avoid an infinite loop, this function will return an error when there are more than 1,000 executions at the same timestamp.

fn init_id(
    &self,
    default: Self::IDT,
    process_log_path: &Path
) -> Result<Self::IDT>
[src]

fn record_progress(&self, path: &Path, id: &str) -> Result<()>[src]

fn run(
    &self,
    writer: &mut impl Writer,
    process_log_path: &Path
) -> Result<()>
[src]

Loading content...