Skip to content

Commit

Permalink
Fix clippy issues
Browse files Browse the repository at this point in the history
  • Loading branch information
guangie88 committed Feb 25, 2018
1 parent 6e4c5cf commit 13f2c01
Show file tree
Hide file tree
Showing 7 changed files with 13 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ fn event_time_main() {
let fruently = Fluent::new("127.0.0.1:24224", "test");
let mut obj = HashMap::new();
let time = time::now();
let thmap = (0..10).fold(&mut obj, |mut acc, i| {
let thmap = (0..10).fold(&mut obj, |acc, i| {
{
acc.insert(format!("fwd{}", i), "fruently".to_string());
}
Expand Down
8 changes: 4 additions & 4 deletions src/event_record.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//! Implement EventTime record manupulation mechanisms.
//! Implement `EventTime` record manupulation mechanisms.
use time;
use time::Tm;
Expand Down Expand Up @@ -50,7 +50,7 @@ impl<T: Serialize> Dumpable for EventRecord<T> {
fn dump(self) -> String {
format!(
"{}\t{}\t{}\n",
time::strftime("%FT%T%z", &self.event[0].get_event_time().get_time()).unwrap(),
time::strftime("%FT%T%z", self.event[0].get_event_time().get_time()).unwrap(),
self.tag,
serde_json::to_string(&self.event[0].get_record()).unwrap()
)
Expand All @@ -59,11 +59,11 @@ impl<T: Serialize> Dumpable for EventRecord<T> {

/// Construct custom encoding json/msgpack style.
///
/// Because `Record` struct should map following style msgpack with ExtType:
/// Because `Record` struct should map following style msgpack with `ExtType`:
///
/// `[tag, [eventtime, record]]`
///
/// ref: https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1#message-modes
/// ref: <https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v1#message-modes>
impl<T: Serialize> Serialize for EventRecord<T> {
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
let mut seq = s.serialize_tuple(3)?;
Expand Down
4 changes: 2 additions & 2 deletions src/event_time.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ impl Serialize for EventTime {
let mut buf = vec![];
buf.write_u8(0xd7).map_err(Error::custom)?;
buf.write_u8(0x00).map_err(Error::custom)?;
buf.write_i32::<BigEndian>(self.clone().time.clone().to_timespec().sec as i32)
buf.write_i32::<BigEndian>(self.clone().time.to_timespec().sec as i32)
.map_err(Error::custom)?;
buf.write_i32::<BigEndian>(self.clone().time.clone().to_timespec().nsec as i32)
buf.write_i32::<BigEndian>(self.clone().time.to_timespec().nsec as i32)
.map_err(Error::custom)?;
serializer.serialize_bytes(&buf)
}
Expand Down
6 changes: 2 additions & 4 deletions src/fluent.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,9 @@ where
}

#[cfg(feature = "time-as-integer")]
type MsgPackSendType<T> where
T: Serialize = Record<T>;
type MsgPackSendType<T> = Record<T>;
#[cfg(not(feature = "time-as-integer"))]
type MsgPackSendType<T> where
T: Serialize = EventRecord<T>;
type MsgPackSendType<T> = EventRecord<T>;

impl<'a, A: ToSocketAddrs> Fluent<'a, A> {
/// Create Fluent type.
Expand Down
6 changes: 2 additions & 4 deletions src/forwardable/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,9 @@ use serde::ser::Serialize;
use event_time::EventTime;

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

pub trait JsonForwardable {
fn post<T: Serialize + Debug + Clone>(self, record: T) -> Result<(), FluentError>;
Expand Down
2 changes: 1 addition & 1 deletion src/record.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ impl<T: Serialize> Dumpable for Record<T> {
///
/// `[tag, unixtime/eventtime, record]`
///
/// ref: https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v0#message-mode
/// ref: <https://github.com/fluent/fluentd/wiki/Forward-Protocol-Specification-v0#message-mode>
impl<T: Serialize> Serialize for Record<T> {
fn serialize<S: Serializer>(&self, s: S) -> Result<S::Ok, S::Error> {
let mut seq = s.serialize_tuple(4)?;
Expand Down
2 changes: 1 addition & 1 deletion src/retry_conf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use std::path::PathBuf;
///
/// `retry_interval = exp ** (multiplier + retry_counts)`
///
/// see: https://github.com/jimmycuadra/retry/blob/v0.4.0/src/lib.rs#L142-L143
/// see: <https://github.com/jimmycuadra/retry/blob/v0.4.0/src/lib.rs#L142-L143>
///
/// You can estimate to caluculate with concrete values like:
///
Expand Down

0 comments on commit 13f2c01

Please sign in to comment.