Skip to content

Commit d2cd820

Browse files
committed
StrBuf -> String
1 parent 584226b commit d2cd820

5 files changed

Lines changed: 68 additions & 68 deletions

File tree

src/error.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ macro_rules! make_errors(
1717
#[allow(missing_doc)]
1818
pub enum PostgresSqlState {
1919
$($error,)+
20-
UnknownSqlState(StrBuf)
20+
UnknownSqlState(String)
2121
}
2222

2323
static STATE_MAP: PhfMap<PostgresSqlState> = phf_map!(
@@ -359,7 +359,7 @@ make_errors!(
359359
/// Reasons a new Postgres connection could fail
360360
pub enum PostgresConnectError {
361361
/// The provided URL could not be parsed
362-
InvalidUrl(StrBuf),
362+
InvalidUrl(String),
363363
/// The URL was missing a user
364364
MissingUser,
365365
/// There was an error opening a socket to the server
@@ -412,7 +412,7 @@ pub enum PostgresErrorPosition {
412412
/// The byte position
413413
pub position: uint,
414414
/// A query generated by the Postgres server
415-
pub query: StrBuf
415+
pub query: String
416416
}
417417
}
418418

@@ -421,59 +421,59 @@ pub struct PostgresDbError {
421421
/// The field contents are ERROR, FATAL, or PANIC (in an error message),
422422
/// or WARNING, NOTICE, DEBUG, INFO, or LOG (in a notice message), or a
423423
/// localized translation of one of these.
424-
pub severity: StrBuf,
424+
pub severity: String,
425425
/// The SQLSTATE code for the error.
426426
pub code: PostgresSqlState,
427427
/// The primary human-readable error message. This should be accurate but
428428
/// terse (typically one line).
429-
pub message: StrBuf,
429+
pub message: String,
430430
/// An optional secondary error message carrying more detail about the
431431
/// problem. Might run to multiple lines.
432-
pub detail: Option<StrBuf>,
432+
pub detail: Option<String>,
433433
/// An optional suggestion what to do about the problem. This is intended
434434
/// to differ from Detail in that it offers advice (potentially
435435
/// inappropriate) rather than hard facts. Might run to multiple lines.
436-
pub hint: Option<StrBuf>,
436+
pub hint: Option<String>,
437437
/// An optional error cursor position into either the original query string
438438
/// or an internally generated query.
439439
pub position: Option<PostgresErrorPosition>,
440440
/// An indication of the context in which the error occurred. Presently
441441
/// this includes a call stack traceback of active procedural language
442442
/// functions and internally-generated queries. The trace is one entry per
443443
/// line, most recent first.
444-
pub where: Option<StrBuf>,
444+
pub where: Option<String>,
445445
/// If the error was associated with a specific database object, the name
446446
/// of the schema containing that object, if any. (PostgreSQL 9.3+)
447-
pub schema: Option<StrBuf>,
447+
pub schema: Option<String>,
448448
/// If the error was associated with a specific table, the name of the
449449
/// table. (Refer to the schema name field for the name of the table's
450450
/// schema.) (PostgreSQL 9.3+)
451-
pub table: Option<StrBuf>,
451+
pub table: Option<String>,
452452
/// If the error was associated with a specific table column, the name of
453453
/// the column. (Refer to the schema and table name fields to identify the
454454
/// table.) (PostgreSQL 9.3+)
455-
pub column: Option<StrBuf>,
455+
pub column: Option<String>,
456456
/// If the error was associated with a specific data type, the name of the
457457
/// data type. (Refer to the schema name field for the name of the data
458458
/// type's schema.) (PostgreSQL 9.3+)
459-
pub datatype: Option<StrBuf>,
459+
pub datatype: Option<String>,
460460
/// If the error was associated with a specific constraint, the name of the
461461
/// constraint. Refer to fields listed above for the associated table or
462462
/// domain. (For this purpose, indexes are treated as constraints, even if
463463
/// they weren't created with constraint syntax.) (PostgreSQL 9.3+)
464-
pub constraint: Option<StrBuf>,
464+
pub constraint: Option<String>,
465465
/// The file name of the source-code location where the error was reported.
466-
pub file: StrBuf,
466+
pub file: String,
467467
/// The line number of the source-code location where the error was
468468
/// reported.
469469
pub line: uint,
470470
/// The name of the source-code routine reporting the error.
471-
pub routine: StrBuf
471+
pub routine: String
472472
}
473473

474474
impl PostgresDbError {
475475
#[doc(hidden)]
476-
pub fn new(fields: Vec<(u8, StrBuf)>) -> PostgresDbError {
476+
pub fn new(fields: Vec<(u8, String)>) -> PostgresDbError {
477477
let mut map: HashMap<_, _> = fields.move_iter().collect();
478478
PostgresDbError {
479479
severity: map.pop(&('S' as u8)).unwrap(),

src/lib.rs

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use postgres::types::ToSql;
1414
1515
struct Person {
1616
id: i32,
17-
name: StrBuf,
17+
name: String,
1818
time_created: Timespec,
1919
data: Option<Vec<u8>>
2020
}
@@ -206,7 +206,7 @@ pub type PostgresResult<T> = Result<T, PostgresError>;
206206
#[deriving(Clone)]
207207
pub enum PostgresConnectTarget {
208208
/// Connect via TCP to the specified host.
209-
TargetTcp(StrBuf),
209+
TargetTcp(String),
210210
/// Connect via a Unix domain socket in the specified directory.
211211
TargetUnix(Path)
212212
}
@@ -224,13 +224,13 @@ pub struct PostgresConnectParams {
224224
///
225225
/// `PostgresConnection::connect` requires a user but `cancel_query` does
226226
/// not.
227-
pub user: Option<StrBuf>,
227+
pub user: Option<String>,
228228
/// An optional password used for authentication
229-
pub password: Option<StrBuf>,
229+
pub password: Option<String>,
230230
/// The database to connect to. Defaults the value of `user`.
231-
pub database: Option<StrBuf>,
231+
pub database: Option<String>,
232232
/// Runtime parameters to be passed to the Postgres backend.
233-
pub options: Vec<(StrBuf, StrBuf)>,
233+
pub options: Vec<(String, String)>,
234234
}
235235

236236
/// A trait implemented by types that can be converted into a
@@ -331,9 +331,9 @@ pub struct PostgresNotification {
331331
/// The process ID of the notifying backend process
332332
pub pid: i32,
333333
/// The name of the channel that the notify has been raised on
334-
pub channel: StrBuf,
334+
pub channel: String,
335335
/// The "payload" string passed from the notifying process
336-
pub payload: StrBuf,
336+
pub payload: String,
337337
}
338338

339339
/// An iterator over asynchronous notifications
@@ -413,7 +413,7 @@ struct InnerPostgresConnection {
413413
notice_handler: Box<PostgresNoticeHandler:Send>,
414414
notifications: RingBuf<PostgresNotification>,
415415
cancel_data: PostgresCancelData,
416-
unknown_types: HashMap<Oid, StrBuf>,
416+
unknown_types: HashMap<Oid, String>,
417417
desynchronized: bool,
418418
finished: bool,
419419
trans_depth: u32,
@@ -523,7 +523,7 @@ impl InnerPostgresConnection {
523523
}
524524
}
525525

526-
fn handle_auth(&mut self, user: StrBuf, pass: Option<StrBuf>)
526+
fn handle_auth(&mut self, user: String, pass: Option<String>)
527527
-> Result<(), PostgresConnectError> {
528528
match try_pg_conn!(self.read_message()) {
529529
AuthenticationOk => return Ok(()),
@@ -649,7 +649,7 @@ impl InnerPostgresConnection {
649649
Ok(())
650650
}
651651

652-
fn get_type_name(&mut self, oid: Oid) -> PostgresResult<StrBuf> {
652+
fn get_type_name(&mut self, oid: Oid) -> PostgresResult<String> {
653653
match self.unknown_types.find(&oid) {
654654
Some(name) => return Ok(name.clone()),
655655
None => {}
@@ -677,7 +677,7 @@ impl InnerPostgresConnection {
677677
}
678678

679679
fn quick_query(&mut self, query: &str)
680-
-> PostgresResult<Vec<Vec<Option<StrBuf>>>> {
680+
-> PostgresResult<Vec<Vec<Option<String>>>> {
681681
check_desync!(self);
682682
try_pg!(self.write_messages([Query { query: query }]));
683683

@@ -687,7 +687,7 @@ impl InnerPostgresConnection {
687687
ReadyForQuery { .. } => break,
688688
DataRow { row } => {
689689
result.push(row.move_iter().map(|opt| {
690-
opt.map(|b| StrBuf::from_utf8(b).unwrap())
690+
opt.map(|b| String::from_utf8(b).unwrap())
691691
}).collect());
692692
}
693693
ErrorResponse { fields } => {
@@ -901,7 +901,7 @@ impl PostgresConnection {
901901
}
902902

903903
fn quick_query(&self, query: &str)
904-
-> PostgresResult<Vec<Vec<Option<StrBuf>>>> {
904+
-> PostgresResult<Vec<Vec<Option<String>>>> {
905905
self.conn.borrow_mut().quick_query(query)
906906
}
907907

@@ -1045,7 +1045,7 @@ impl<'conn> PostgresTransaction<'conn> {
10451045
/// A prepared statement
10461046
pub struct PostgresStatement<'conn> {
10471047
conn: &'conn PostgresConnection,
1048-
name: StrBuf,
1048+
name: String,
10491049
param_types: Vec<PostgresType>,
10501050
result_desc: Vec<ResultDescription>,
10511051
next_portal_id: Cell<uint>,
@@ -1244,15 +1244,15 @@ impl<'conn> PostgresStatement<'conn> {
12441244
#[deriving(Eq)]
12451245
pub struct ResultDescription {
12461246
/// The name of the column
1247-
pub name: StrBuf,
1247+
pub name: String,
12481248
/// The type of the data in the column
12491249
pub ty: PostgresType
12501250
}
12511251

12521252
/// An iterator over the resulting rows of a query.
12531253
pub struct PostgresRows<'stmt> {
12541254
stmt: &'stmt PostgresStatement<'stmt>,
1255-
name: StrBuf,
1255+
name: String,
12561256
data: RingBuf<Vec<Option<Vec<u8>>>>,
12571257
row_limit: uint,
12581258
more_rows: bool,
@@ -1416,7 +1416,7 @@ impl<'stmt, I: RowIndex+Clone+fmt::Show, T: FromSql> Index<I, T>
14161416
/// # let mut result = stmt.query([]).unwrap();
14171417
/// # let row = result.next().unwrap();
14181418
/// let foo: i32 = row[1];
1419-
/// let bar: StrBuf = row["bar"];
1419+
/// let bar: String = row["bar"];
14201420
/// ```
14211421
fn index(&self, idx: &I) -> T {
14221422
match self.get(idx.clone()) {

src/message.rs

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,30 +24,30 @@ pub enum BackendMessage {
2424
BindComplete,
2525
CloseComplete,
2626
CommandComplete {
27-
pub tag: StrBuf,
27+
pub tag: String,
2828
},
2929
DataRow {
3030
pub row: Vec<Option<Vec<u8>>>
3131
},
3232
EmptyQueryResponse,
3333
ErrorResponse {
34-
pub fields: Vec<(u8, StrBuf)>
34+
pub fields: Vec<(u8, String)>
3535
},
3636
NoData,
3737
NoticeResponse {
38-
pub fields: Vec<(u8, StrBuf)>
38+
pub fields: Vec<(u8, String)>
3939
},
4040
NotificationResponse {
4141
pub pid: i32,
42-
pub channel: StrBuf,
43-
pub payload: StrBuf,
42+
pub channel: String,
43+
pub payload: String,
4444
},
4545
ParameterDescription {
4646
pub types: Vec<Oid>
4747
},
4848
ParameterStatus {
49-
pub parameter: StrBuf,
50-
pub value: StrBuf,
49+
pub parameter: String,
50+
pub value: String,
5151
},
5252
ParseComplete,
5353
PortalSuspended,
@@ -60,7 +60,7 @@ pub enum BackendMessage {
6060
}
6161

6262
pub struct RowDescriptionEntry {
63-
pub name: StrBuf,
63+
pub name: String,
6464
pub table_oid: Oid,
6565
pub column_id: i16,
6666
pub type_oid: Oid,
@@ -110,7 +110,7 @@ pub enum FrontendMessage<'a> {
110110
},
111111
StartupMessage {
112112
pub version: i32,
113-
pub parameters: &'a [(StrBuf, StrBuf)]
113+
pub parameters: &'a [(String, String)]
114114
},
115115
Sync,
116116
Terminate
@@ -237,14 +237,14 @@ impl<W: Writer> WriteMessage for W {
237237

238238
#[doc(hidden)]
239239
trait ReadCStr {
240-
fn read_cstr(&mut self) -> IoResult<StrBuf>;
240+
fn read_cstr(&mut self) -> IoResult<String>;
241241
}
242242

243243
impl<R: Buffer> ReadCStr for R {
244-
fn read_cstr(&mut self) -> IoResult<StrBuf> {
244+
fn read_cstr(&mut self) -> IoResult<String> {
245245
let mut buf = try!(self.read_until(0));
246246
buf.pop();
247-
Ok(StrBuf::from_utf8(buf).unwrap())
247+
Ok(String::from_utf8(buf).unwrap())
248248
}
249249
}
250250

@@ -294,7 +294,7 @@ impl<R: Reader> ReadMessage for R {
294294
}
295295
}
296296

297-
fn read_fields(buf: &mut MemReader) -> IoResult<Vec<(u8, StrBuf)>> {
297+
fn read_fields(buf: &mut MemReader) -> IoResult<Vec<(u8, String)>> {
298298
let mut fields = Vec::new();
299299
loop {
300300
let ty = try!(buf.read_u8());

src/test.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ fn test_unix_connection() {
113113
let conn = or_fail!(PostgresConnection::connect("postgres://postgres@localhost", &NoSsl));
114114
let stmt = or_fail!(conn.prepare("SHOW unix_socket_directories"));
115115
let result = or_fail!(stmt.query([]));
116-
let unix_socket_directories: StrBuf = result.map(|row| row[1]).next().unwrap();
116+
let unix_socket_directories: String = result.map(|row| row[1]).next().unwrap();
117117

118118
if unix_socket_directories.is_empty() {
119119
fail!("can't test connect_unix; unix_socket_directories is empty");
@@ -1028,6 +1028,6 @@ fn test_pg_database_datname() {
10281028
let mut result = or_fail!(stmt.query([]));
10291029

10301030
let next = result.next().unwrap();
1031-
or_fail!(next.get::<uint, StrBuf>(1));
1032-
or_fail!(next.get::<&str, StrBuf>("datname"));
1031+
or_fail!(next.get::<uint, String>(1));
1032+
or_fail!(next.get::<&str, String>("datname"));
10331033
}

0 commit comments

Comments
 (0)