Implement Debug for SessionInfo and Display for Type

This commit is contained in:
Steven Fackler 2015-12-27 13:47:32 -07:00
parent 1188eb108a
commit c34fa5ccd8

View File

@ -90,6 +90,14 @@ impl<'a> SessionInfo<'a> {
}
}
impl<'a> fmt::Debug for SessionInfo<'a> {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
fmt.debug_struct("SessionInfo")
.field("parameters", &self.conn.parameters)
.finish()
}
}
/// A Postgres OID.
pub type Oid = u32;
@ -137,6 +145,16 @@ macro_rules! make_postgres_type {
}
}
impl fmt::Display for Type {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match self.schema() {
"public" | "pg_catalog" => {}
schema => try!(write!(fmt, "{}.", schema)),
}
fmt.write_str(self.name())
}
}
impl Type {
/// Returns the `Type` corresponding to the provided `Oid` if it
/// corresponds to a built-in type.
@ -571,7 +589,7 @@ pub struct WrongType(Type);
impl fmt::Display for WrongType {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
write!(fmt, "cannot convert to or from a Postgres value of type {:?}", self.0)
write!(fmt, "cannot convert to or from a Postgres value of type `{}`", self.0)
}
}