use std::error;
/// Available encoding character sets
+#[deriving(Copy)]
pub enum CharacterSet {
/// The standard character set (uses `+` and `/`)
Standard,
UrlSafe
}
-impl Copy for CharacterSet {}
-
/// Available newline types
+#[deriving(Copy)]
pub enum Newline {
/// A linefeed (i.e. Unix-style newline)
LF,
CRLF
}
-impl Copy for Newline {}
-
/// Contains configuration parameters for `to_base64`.
+#[deriving(Copy)]
pub struct Config {
/// Character set to use
pub char_set: CharacterSet,
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};
}
/// 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),
InvalidBase64Length,
}
-impl Copy for FromBase64Error {}
-
impl fmt::Show for FromBase64Error {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
}
/// 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),
InvalidHexLength,
}
-impl Copy for FromHexError {}
-
impl fmt::Show for FromHexError {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match *self {
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,
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;