1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
//! Implement concrete sending record(s) specifications.

use time;
use error::FluentError;
use std::fmt::Debug;
use serde::ser::Serialize;
#[cfg(not(feature = "time-as-integer"))]
use event_time::EventTime;

#[cfg(not(feature = "time-as-integer"))]
pub type Entry<T> where
    T: Serialize = (EventTime, T);
#[cfg(feature = "time-as-integer")]
pub type Entry<T> where
    T: Serialize = (i64, T);

pub trait JsonForwardable {
    fn post<T: Serialize + Debug + Clone>(self, record: T) -> Result<(), FluentError>;
    fn post_with_time<T: Serialize + Debug + Clone>(self, record: T, time: time::Tm) -> Result<(), FluentError>;
}

pub trait MsgpackForwardable {
    fn post<T: Serialize + Debug>(self, record: T) -> Result<(), FluentError>;
    fn post_with_time<T: Serialize + Debug>(self, record: T, time: time::Tm) -> Result<(), FluentError>;
}

pub trait Forwardable {
    fn post<T: Serialize + Debug>(self, entries: Vec<Entry<T>>) -> Result<(), FluentError>;
}

pub mod json;
pub mod msgpack;
pub mod forward;