Skip to content
This repository has been archived by the owner on Nov 6, 2020. It is now read-only.

Commit

Permalink
[ethcore-types]: DataFormat add docs + tabify
Browse files Browse the repository at this point in the history
  • Loading branch information
niklasad1 committed Sep 11, 2019
1 parent 387d0dc commit 75d0e37
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions ethcore/types/src/data_format.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,24 +20,26 @@ use std::str::FromStr;
/// Format for importing/exporting blocks
#[derive(Debug, PartialEq)]
pub enum DataFormat {
Hex,
Binary,
/// Hexadecimal format
Hex,
/// Binary format
Binary,
}

impl Default for DataFormat {
fn default() -> Self {
DataFormat::Binary
}
fn default() -> Self {
DataFormat::Binary
}
}

impl FromStr for DataFormat {
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"binary" | "bin" => Ok(DataFormat::Binary),
"hex" => Ok(DataFormat::Hex),
x => Err(format!("Invalid format: {}", x))
}
}
type Err = String;

fn from_str(s: &str) -> Result<Self, Self::Err> {
match s {
"binary" | "bin" => Ok(DataFormat::Binary),
"hex" => Ok(DataFormat::Hex),
x => Err(format!("Invalid format: {}", x))
}
}
}

0 comments on commit 75d0e37

Please sign in to comment.