(&self, cursor: &mut Cursor<&[u8]>, _length: u32)
| 255 | } |
| 256 | |
| 257 | async fn parse_bind(&self, cursor: &mut Cursor<&[u8]>, _length: u32) -> Result<FrontendMessage, ParseError> { |
| 258 | let portal_name = self.read_cstring(cursor).await?; |
| 259 | let statement_name = self.read_cstring(cursor).await?; |
| 260 | |
| 261 | let format_count = cursor.read_u16::<BigEndian>()? as usize; |
| 262 | if format_count > self.max_param_count { |
| 263 | return Err(ParseError::ProtocolViolation("Too many format codes".to_string())); |
| 264 | } |
| 265 | |
| 266 | let mut formats = Vec::with_capacity(format_count); |
| 267 | for _ in 0..format_count { |
| 268 | formats.push(cursor.read_i16::<BigEndian>()?); |
| 269 | } |
| 270 | |
| 271 | let param_count = cursor.read_u16::<BigEndian>()? as usize; |
| 272 | if param_count > self.max_param_count { |
| 273 | return Err(ParseError::ProtocolViolation("Too many parameters".to_string())); |
| 274 | } |
| 275 | |
| 276 | let mut values = Vec::with_capacity(param_count); |
| 277 | for _ in 0..param_count { |
| 278 | let value_length = cursor.read_i32::<BigEndian>()?; |
| 279 | if value_length == -1 { |
| 280 | values.push(None); // NULL value |
| 281 | } else { |
| 282 | if value_length < 0 || value_length as usize > self.max_string_length { |
| 283 | return Err(ParseError::ProtocolViolation("Invalid parameter length".to_string())); |
| 284 | } |
| 285 | let mut value = vec![0u8; value_length as usize]; |
| 286 | cursor.read_exact(&mut value)?; |
| 287 | values.push(Some(value)); |
| 288 | } |
| 289 | } |
| 290 | |
| 291 | let result_format_count = cursor.read_u16::<BigEndian>()? as usize; |
| 292 | if result_format_count > self.max_param_count { |
| 293 | return Err(ParseError::ProtocolViolation("Too many result format codes".to_string())); |
| 294 | } |
| 295 | |
| 296 | let mut result_formats = Vec::with_capacity(result_format_count); |
| 297 | for _ in 0..result_format_count { |
| 298 | result_formats.push(cursor.read_i16::<BigEndian>()?); |
| 299 | } |
| 300 | |
| 301 | Ok(FrontendMessage::Bind { |
| 302 | portal: portal_name, |
| 303 | statement: statement_name, |
| 304 | formats, |
| 305 | values, |
| 306 | result_formats, |
| 307 | }) |
| 308 | } |
| 309 | |
| 310 | async fn parse_execute(&self, cursor: &mut Cursor<&[u8]>, _length: u32) -> Result<FrontendMessage, ParseError> { |
| 311 | let portal_name = self.read_cstring(cursor).await?; |
no test coverage detected