Skip to content

Commit b99faec

Browse files
committed
Rename extension method
1 parent 91f2453 commit b99faec

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

message.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,12 +121,12 @@ pub enum FrontendMessage<'a> {
121121
Terminate
122122
}
123123

124-
trait WriteString {
125-
fn write_string(&mut self, s: &str);
124+
trait WriteCStr {
125+
fn write_cstr(&mut self, s: &str);
126126
}
127127

128-
impl<W: Writer> WriteString for W {
129-
fn write_string(&mut self, s: &str) {
128+
impl<W: Writer> WriteCStr for W {
129+
fn write_cstr(&mut self, s: &str) {
130130
self.write(s.as_bytes());
131131
self.write_u8(0);
132132
}
@@ -145,8 +145,8 @@ impl<W: Writer> WriteMessage for W {
145145
match *message {
146146
Bind { portal, statement, formats, values, result_formats } => {
147147
ident = Some('B');
148-
buf.write_string(portal);
149-
buf.write_string(statement);
148+
buf.write_cstr(portal);
149+
buf.write_cstr(statement);
150150

151151
buf.write_be_i16(formats.len() as i16);
152152
for format in formats.iter() {
@@ -179,40 +179,40 @@ impl<W: Writer> WriteMessage for W {
179179
Close { variant, name } => {
180180
ident = Some('C');
181181
buf.write_u8(variant);
182-
buf.write_string(name);
182+
buf.write_cstr(name);
183183
}
184184
Describe { variant, name } => {
185185
ident = Some('D');
186186
buf.write_u8(variant);
187-
buf.write_string(name);
187+
buf.write_cstr(name);
188188
}
189189
Execute { portal, max_rows } => {
190190
ident = Some('E');
191-
buf.write_string(portal);
191+
buf.write_cstr(portal);
192192
buf.write_be_i32(max_rows);
193193
}
194194
Parse { name, query, param_types } => {
195195
ident = Some('P');
196-
buf.write_string(name);
197-
buf.write_string(query);
196+
buf.write_cstr(name);
197+
buf.write_cstr(query);
198198
buf.write_be_i16(param_types.len() as i16);
199199
for ty in param_types.iter() {
200200
buf.write_be_i32(*ty);
201201
}
202202
}
203203
PasswordMessage { password } => {
204204
ident = Some('p');
205-
buf.write_string(password);
205+
buf.write_cstr(password);
206206
}
207207
Query { query } => {
208208
ident = Some('Q');
209-
buf.write_string(query);
209+
buf.write_cstr(query);
210210
}
211211
StartupMessage { version, parameters } => {
212212
buf.write_be_i32(version);
213213
for &(ref k, ref v) in parameters.iter() {
214-
buf.write_string(k.as_slice());
215-
buf.write_string(v.as_slice());
214+
buf.write_cstr(k.as_slice());
215+
buf.write_cstr(v.as_slice());
216216
}
217217
buf.write_u8(0);
218218
}

0 commit comments

Comments
 (0)