libserialize: use #[deriving(Copy)]
This commit is contained in:
parent
1d25271e05
commit
2df30a47e2
3 changed files with 7 additions and 16 deletions
|
@ -19,6 +19,7 @@ use std::fmt;
|
||||||
use std::error;
|
use std::error;
|
||||||
|
|
||||||
/// Available encoding character sets
|
/// Available encoding character sets
|
||||||
|
#[deriving(Copy)]
|
||||||
pub enum CharacterSet {
|
pub enum CharacterSet {
|
||||||
/// The standard character set (uses `+` and `/`)
|
/// The standard character set (uses `+` and `/`)
|
||||||
Standard,
|
Standard,
|
||||||
|
@ -26,9 +27,8 @@ pub enum CharacterSet {
|
||||||
UrlSafe
|
UrlSafe
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for CharacterSet {}
|
|
||||||
|
|
||||||
/// Available newline types
|
/// Available newline types
|
||||||
|
#[deriving(Copy)]
|
||||||
pub enum Newline {
|
pub enum Newline {
|
||||||
/// A linefeed (i.e. Unix-style newline)
|
/// A linefeed (i.e. Unix-style newline)
|
||||||
LF,
|
LF,
|
||||||
|
@ -36,9 +36,8 @@ pub enum Newline {
|
||||||
CRLF
|
CRLF
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for Newline {}
|
|
||||||
|
|
||||||
/// Contains configuration parameters for `to_base64`.
|
/// Contains configuration parameters for `to_base64`.
|
||||||
|
#[deriving(Copy)]
|
||||||
pub struct Config {
|
pub struct Config {
|
||||||
/// Character set to use
|
/// Character set to use
|
||||||
pub char_set: CharacterSet,
|
pub char_set: CharacterSet,
|
||||||
|
@ -50,8 +49,6 @@ pub struct Config {
|
||||||
pub line_length: Option<uint>
|
pub line_length: Option<uint>
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for Config {}
|
|
||||||
|
|
||||||
/// Configuration for RFC 4648 standard base64 encoding
|
/// Configuration for RFC 4648 standard base64 encoding
|
||||||
pub static STANDARD: Config =
|
pub static STANDARD: Config =
|
||||||
Config {char_set: Standard, newline: Newline::CRLF, pad: true, line_length: None};
|
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
|
/// Errors that can occur when decoding a base64 encoded string
|
||||||
|
#[deriving(Copy)]
|
||||||
pub enum FromBase64Error {
|
pub enum FromBase64Error {
|
||||||
/// The input contained a character not part of the base64 format
|
/// The input contained a character not part of the base64 format
|
||||||
InvalidBase64Byte(u8, uint),
|
InvalidBase64Byte(u8, uint),
|
||||||
|
@ -187,8 +185,6 @@ pub enum FromBase64Error {
|
||||||
InvalidBase64Length,
|
InvalidBase64Length,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for FromBase64Error {}
|
|
||||||
|
|
||||||
impl fmt::Show for FromBase64Error {
|
impl fmt::Show for FromBase64Error {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
|
|
|
@ -61,6 +61,7 @@ pub trait FromHex for Sized? {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Errors that can occur when decoding a hex encoded string
|
/// Errors that can occur when decoding a hex encoded string
|
||||||
|
#[deriving(Copy)]
|
||||||
pub enum FromHexError {
|
pub enum FromHexError {
|
||||||
/// The input contained a character not part of the hex format
|
/// The input contained a character not part of the hex format
|
||||||
InvalidHexCharacter(char, uint),
|
InvalidHexCharacter(char, uint),
|
||||||
|
@ -68,8 +69,6 @@ pub enum FromHexError {
|
||||||
InvalidHexLength,
|
InvalidHexLength,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for FromHexError {}
|
|
||||||
|
|
||||||
impl fmt::Show for FromHexError {
|
impl fmt::Show for FromHexError {
|
||||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||||
match *self {
|
match *self {
|
||||||
|
|
|
@ -226,7 +226,7 @@ pub type Array = Vec<Json>;
|
||||||
pub type Object = BTreeMap<string::String, Json>;
|
pub type Object = BTreeMap<string::String, Json>;
|
||||||
|
|
||||||
/// The errors that can arise while parsing a JSON stream.
|
/// The errors that can arise while parsing a JSON stream.
|
||||||
#[deriving(Clone, PartialEq)]
|
#[deriving(Clone, Copy, PartialEq)]
|
||||||
pub enum ErrorCode {
|
pub enum ErrorCode {
|
||||||
InvalidSyntax,
|
InvalidSyntax,
|
||||||
InvalidNumber,
|
InvalidNumber,
|
||||||
|
@ -247,17 +247,13 @@ pub enum ErrorCode {
|
||||||
NotUtf8,
|
NotUtf8,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for ErrorCode {}
|
#[deriving(Clone, Copy, PartialEq, Show)]
|
||||||
|
|
||||||
#[deriving(Clone, PartialEq, Show)]
|
|
||||||
pub enum ParserError {
|
pub enum ParserError {
|
||||||
/// msg, line, col
|
/// msg, line, col
|
||||||
SyntaxError(ErrorCode, uint, uint),
|
SyntaxError(ErrorCode, uint, uint),
|
||||||
IoError(io::IoErrorKind, &'static str),
|
IoError(io::IoErrorKind, &'static str),
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Copy for ParserError {}
|
|
||||||
|
|
||||||
// Builder and Parser have the same errors.
|
// Builder and Parser have the same errors.
|
||||||
pub type BuilderError = ParserError;
|
pub type BuilderError = ParserError;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue