Merge pull request #79 from kyledewey/enum_namespace_fix

Added imports for members of enums
This commit is contained in:
Steven Fackler 2014-11-18 12:13:05 -05:00
commit a6f0edbd0d
7 changed files with 53 additions and 36 deletions

View File

@ -12,6 +12,9 @@ use phf;
use Result;
use types::Type;
use self::ConnectError::*;
use self::Error::*;
macro_rules! make_errors(
($($code:expr => $error:ident),+) => (
/// SQLSTATE error codes

View File

@ -6,7 +6,10 @@ use std::io::{Stream, IoResult};
use {ConnectParams, SslMode, ConnectTarget, ConnectError};
use message;
use message::{SslRequest, WriteMessage};
use message::WriteMessage;
use message::FrontendMessage::SslRequest;
use self::InternalStream::{TcpStream, UnixStream};
const DEFAULT_PORT: Port = 5432;

View File

@ -3,6 +3,9 @@ use std::mem;
use types::Oid;
use self::BackendMessage::*;
use self::FrontendMessage::*;
pub const PROTOCOL_VERSION: u32 = 0x0003_0000;
pub const CANCEL_CODE: u32 = 80877102;
pub const SSL_CODE: u32 = 80877103;

View File

@ -3,6 +3,9 @@
use std::mem;
use std::slice;
use self::ArrayParent::{SliceParent, MutSliceParent, BaseParent};
use self::MutArrayParent::{MutSliceMutParent, MutBaseParent};
/// Information about a dimension of an array
#[deriving(PartialEq, Eq, Clone)]
pub struct DimensionInfo {

View File

@ -5,8 +5,9 @@ use std::io::{ByRefReader, MemWriter, BufReader};
use self::Type::*;
use Result;
use error::{PgWrongType, PgWasNull, PgBadData};
use types::range::{Inclusive, Exclusive, Range};
use error::Error::{PgWrongType, PgWasNull, PgBadData};
use types::range::Range;
use types::range::BoundType::{Inclusive, Exclusive};
macro_rules! check_types(
($($expected:pat)|+, $actual:ident) => (

View File

@ -3,6 +3,10 @@ use std::fmt;
use std::i32;
use std::i64;
use self::BoundSide::{Lower, Upper};
use self::BoundType::{Inclusive, Exclusive};
use self::InnerRange::{Empty, Normal};
/// The `range!` macro can make it easier to create ranges. It roughly mirrors
/// traditional mathematic range syntax.
///

View File

@ -278,8 +278,8 @@ fn get_authority(rawurl: &str) ->
}
let len = rawurl.len();
let mut st = Start;
let mut input = Digit; // most restricted, start here.
let mut st = State::Start;
let mut input = Input::Digit; // most restricted, start here.
let mut userinfo = None;
let mut host = "";
@ -298,15 +298,15 @@ fn get_authority(rawurl: &str) ->
'0' ... '9' => (),
'A' ... 'F'
| 'a' ... 'f' => {
if input == Digit {
input = Hex;
if input == Input::Digit {
input = Input::Hex;
}
}
'G' ... 'Z'
| 'g' ... 'z'
| '-' | '.' | '_' | '~' | '%'
| '&' |'\'' | '(' | ')' | '+'
| '!' | '*' | ',' | ';' | '=' => input = Unreserved,
| '!' | '*' | ',' | ';' | '=' => input = Input::Unreserved,
':' | '@' | '?' | '#' | '/' => {
// separators, don't change anything
}
@ -318,61 +318,61 @@ fn get_authority(rawurl: &str) ->
':' => {
colon_count += 1;
match st {
Start => {
State::Start => {
pos = i;
st = PassHostPort;
st = State::PassHostPort;
}
PassHostPort => {
State::PassHostPort => {
// multiple colons means ipv6 address.
if input == Unreserved {
if input == Input::Unreserved {
return Err(
"Illegal characters in IPv6 address.".to_string());
}
st = Ip6Host;
st = State::Ip6Host;
}
InHost => {
State::InHost => {
pos = i;
if input == Unreserved {
if input == Input::Unreserved {
// must be port
host = rawurl.slice(begin, i);
st = InPort;
st = State::InPort;
} else {
// can't be sure whether this is an ipv6 address or a port
st = Ip6Port;
st = State::Ip6Port;
}
}
Ip6Port => {
if input == Unreserved {
State::Ip6Port => {
if input == Input::Unreserved {
return Err("Illegal characters in authority.".to_string());
}
st = Ip6Host;
st = State::Ip6Host;
}
Ip6Host => {
State::Ip6Host => {
if colon_count > 7 {
host = rawurl.slice(begin, i);
pos = i;
st = InPort;
st = State::InPort;
}
}
_ => return Err("Invalid ':' in authority.".to_string()),
}
input = Digit; // reset input class
input = Input::Digit; // reset input class
}
'@' => {
input = Digit; // reset input class
input = Input::Digit; // reset input class
colon_count = 0; // reset count
match st {
Start => {
State::Start => {
let user = rawurl.slice(begin, i).to_string();
userinfo = Some(UserInfo::new(user, None));
st = InHost;
st = State::InHost;
}
PassHostPort => {
State::PassHostPort => {
let user = rawurl.slice(begin, pos).to_string();
let pass = rawurl.slice(pos+1, i).to_string();
userinfo = Some(UserInfo::new(user, Some(pass)));
st = InHost;
st = State::InHost;
}
_ => return Err("Invalid '@' in authority.".to_string()),
}
@ -389,19 +389,19 @@ fn get_authority(rawurl: &str) ->
// finish up
match st {
Start => host = rawurl.slice(begin, end),
PassHostPort
| Ip6Port => {
if input != Digit {
State::Start => host = rawurl.slice(begin, end),
State::PassHostPort
| State::Ip6Port => {
if input != Input::Digit {
return Err("Non-digit characters in port.".to_string());
}
host = rawurl.slice(begin, pos);
port = Some(rawurl.slice(pos+1, end));
}
Ip6Host
| InHost => host = rawurl.slice(begin, end),
InPort => {
if input != Digit {
State::Ip6Host
| State::InHost => host = rawurl.slice(begin, end),
State::InPort => {
if input != Input::Digit {
return Err("Non-digit characters in port.".to_string());
}
port = Some(rawurl.slice(pos+1, end));