libserialize: use #[deriving(Copy)]

This commit is contained in:
Jorge Aparicio 2014-12-14 23:20:43 -05:00
parent 1d25271e05
commit 2df30a47e2
3 changed files with 7 additions and 16 deletions

View File

@ -19,6 +19,7 @@ use std::fmt;
use std::error;
/// Available encoding character sets
#[deriving(Copy)]
pub enum CharacterSet {
/// The standard character set (uses `+` and `/`)
Standard,
@ -26,9 +27,8 @@ pub enum CharacterSet {
UrlSafe
}
impl Copy for CharacterSet {}
/// Available newline types
#[deriving(Copy)]
pub enum Newline {
/// A linefeed (i.e. Unix-style newline)
LF,
@ -36,9 +36,8 @@ pub enum Newline {
CRLF
}
impl Copy for Newline {}
/// Contains configuration parameters for `to_base64`.
#[deriving(Copy)]
pub struct Config {
/// Character set to use
pub char_set: CharacterSet,
@ -50,8 +49,6 @@ pub struct Config {
pub line_length: Option<uint>
}
impl Copy for Config {}
/// Configuration for RFC 4648 standard base64 encoding
pub static STANDARD: Config =
Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: None};
@ -180,6 +177,7 @@ pub trait FromBase64 for Sized? {
}
/// Errors that can occur when decoding a base64 encoded string
#[deriving(Copy)]
pub enum FromBase64Error {
/// The input contained a character not part of the base64 format
InvalidBase64Byte(u8, uint),
@ -187,8 +185,6 @@ pub enum FromBase64Error {
InvalidBase64Length,
}
impl Copy for FromBase64Error {}
impl fmt::Show for FromBase64Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {

View File

@ -61,6 +61,7 @@ pub trait FromHex for Sized? {
}
/// Errors that can occur when decoding a hex encoded string
#[deriving(Copy)]
pub enum FromHexError {
/// The input contained a character not part of the hex format
InvalidHexCharacter(char, uint),
@ -68,8 +69,6 @@ pub enum FromHexError {
InvalidHexLength,
}
impl Copy for FromHexError {}
impl fmt::Show for FromHexError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {

View File

@ -226,7 +226,7 @@ pub type Array = Vec<Json>;
pub type Object = BTreeMap<string::String, Json>;
/// The errors that can arise while parsing a JSON stream.
#[deriving(Clone, PartialEq)]
#[deriving(Clone, Copy, PartialEq)]
pub enum ErrorCode {
InvalidSyntax,
InvalidNumber,
@ -247,17 +247,13 @@ pub enum ErrorCode {
NotUtf8,
}
impl Copy for ErrorCode {}
#[deriving(Clone, PartialEq, Show)]
#[deriving(Clone, Copy, PartialEq, Show)]
pub enum ParserError {
/// msg, line, col
SyntaxError(ErrorCode, uint, uint),
IoError(io::IoErrorKind, &'static str),
}
impl Copy for ParserError {}
// Builder and Parser have the same errors.
pub type BuilderError = ParserError;