feat: implement Order message type

This commit is contained in:
Daniel Akhterov 2020-06-11 18:58:06 -07:00
parent 9ce596d492
commit 98a0de2cfd
No known key found for this signature in database
GPG key ID: B1E37688C42BC6E8
4 changed files with 24 additions and 0 deletions

View file

@ -12,6 +12,7 @@ use crate::mssql::protocol::error::Error as ProtocolError;
use crate::mssql::protocol::info::Info;
use crate::mssql::protocol::login_ack::LoginAck;
use crate::mssql::protocol::message::{Message, MessageType};
use crate::mssql::protocol::order::Order;
use crate::mssql::protocol::packet::{PacketHeader, PacketType, Status};
use crate::mssql::protocol::return_status::ReturnStatus;
use crate::mssql::protocol::return_value::ReturnValue;
@ -148,6 +149,7 @@ impl MssqlStream {
MessageType::Done => Message::Done(Done::get(buf)?),
MessageType::DoneInProc => Message::DoneInProc(Done::get(buf)?),
MessageType::DoneProc => Message::DoneProc(Done::get(buf)?),
MessageType::Order => Message::Order(Order::get(buf)?),
MessageType::Error => {
let error = ProtocolError::get(buf)?;

View file

@ -2,6 +2,7 @@ use bytes::{Buf, Bytes};
use crate::mssql::protocol::done::Done;
use crate::mssql::protocol::login_ack::LoginAck;
use crate::mssql::protocol::order::Order;
use crate::mssql::protocol::return_status::ReturnStatus;
use crate::mssql::protocol::return_value::ReturnValue;
use crate::mssql::protocol::row::Row;
@ -15,6 +16,7 @@ pub(crate) enum Message {
Row(Row),
ReturnStatus(ReturnStatus),
ReturnValue(ReturnValue),
Order(Order),
}
#[derive(Debug)]
@ -31,6 +33,7 @@ pub(crate) enum MessageType {
ColMetaData,
ReturnStatus,
ReturnValue,
Order,
}
impl MessageType {
@ -45,6 +48,7 @@ impl MessageType {
0xd2 => MessageType::NbcRow,
0xe3 => MessageType::EnvChange,
0x79 => MessageType::ReturnStatus,
0xa9 => MessageType::Order,
0xfd => MessageType::Done,
0xfe => MessageType::DoneProc,
0xff => MessageType::DoneInProc,

View file

@ -7,6 +7,7 @@ pub(crate) mod info;
pub(crate) mod login;
pub(crate) mod login_ack;
pub(crate) mod message;
pub(crate) mod order;
pub(crate) mod packet;
pub(crate) mod pre_login;
pub(crate) mod return_status;

View file

@ -0,0 +1,17 @@
use bytes::{Buf, Bytes};
use crate::error::Error;
#[derive(Debug)]
pub(crate) struct Order {
columns: Bytes,
}
impl Order {
pub(crate) fn get(buf: &mut Bytes) -> Result<Self, Error> {
let len = buf.get_u16_le();
let columns = buf.split_to(len as usize);
Ok(Self { columns })
}
}