Skip to content

Commit 7b6b06c

Browse files
authored
Merge pull request #27 from skytable/protocol/new-decoder
Fix protocol decoder and response issues
2 parents 15761f7 + 0e6add5 commit 7b6b06c

File tree

8 files changed

+831
-761
lines changed

8 files changed

+831
-761
lines changed

CHANGELOG.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,54 +2,65 @@
22

33
All changes in this project will be noted in this file.
44

5-
### 0.8.7 (unreleased)
5+
## 0.8.8
6+
7+
### Fixes
8+
9+
- Fixed response decoder and handling issues
10+
11+
### Additions
12+
13+
- Added `FromResponse` for `Vec<Row>`
14+
- Added `SQParam` impl for `&Vec<u8>`
15+
16+
## 0.8.7
617

718
> - **Field change warnings**:
819
> - The `Config` struct now has one additional field. This is not a breaking change because the functionality of the library remains unchanged
920
10-
#### Additions
21+
### Additions
1122

1223
- Added support for pipelines
1324
- Added `Response::parse` to convert a response into compatible types
1425

15-
### 0.8.6
26+
## 0.8.6
1627

1728
Reduced allocations in `Query`.
1829

19-
### 0.8.5
30+
## 0.8.5
2031

2132
Fixed bugs with the derive macros.
2233

23-
### 0.8.4
34+
## 0.8.4
2435

2536
> **Yanked version**
2637
2738
Fixed an issue with single-item struct derives when using the `Response` macro.
2839

29-
### 0.8.3
40+
## 0.8.3
3041

3142
Added the following implementations:
3243
- `FromResponse` for `Row`
3344
- `FromValue` for `Value` (this was erroneously missing)
3445
- Added the `Value::parse` and `Value::parse_cloned` member methods
3546
- Added `Row::into_first` and `Row::into_first_as` member methods
3647

37-
### 0.8.2
48+
## 0.8.2
3849

3950
Support deriving queries and responses.
4051

41-
### 0.8.1
52+
## 0.8.1
4253

4354
Fixed issues with documentation
4455

4556
## 0.8.0
4657

47-
#### New features
58+
### New features
4859
- Completely up to date for Skyhash 2.0
4960
- New query API interface for Skytable Octave (completely breaking!)
5061
- No longer depends on OpenSSL
5162

52-
#### Breaking changes
63+
### Breaking changes
5364
The enter query interface as changed and is incompatible with previous driver versions. Please consider reading the Skytable
5465
Octave upgrade guide.
5566

src/io/aio.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,7 @@ use {
2626
error::{ClientResult, ConnectionSetupError, Error},
2727
protocol::{
2828
handshake::{ClientHandshake, ServerHandshake},
29-
state_init::{DecodeState, MRespState, PipelineResult, RState},
30-
Decoder,
29+
DecodeState, Decoder, MRespState, PipelineResult, RState,
3130
},
3231
query::Pipeline,
3332
response::{FromResponse, Response},
@@ -168,11 +167,12 @@ impl<C: AsyncWriteExt + AsyncReadExt + Unpin> TcpConnection<C> {
168167
return Err(Error::IoError(std::io::ErrorKind::ConnectionReset.into()));
169168
}
170169
self.buf.extend_from_slice(&buf[..n]);
171-
let mut decoder = Decoder::new(&self.buf, cursor);
172-
match decoder.validate_pipe(pipeline.query_count(), state) {
170+
let (_state, _position) =
171+
Decoder::new(&self.buf, cursor).validate_pipe(pipeline.query_count(), state);
172+
match _state {
173173
PipelineResult::Completed(r) => return Ok(r),
174174
PipelineResult::Pending(_state) => {
175-
cursor = decoder.position();
175+
cursor = _position;
176176
state = _state;
177177
}
178178
PipelineResult::Error(e) => return Err(e.into()),
@@ -198,13 +198,13 @@ impl<C: AsyncWriteExt + AsyncReadExt + Unpin> TcpConnection<C> {
198198
continue;
199199
}
200200
self.buf.extend_from_slice(&buf[..n]);
201-
let mut decoder = Decoder::new(&self.buf, cursor);
202-
match decoder.validate_response(state) {
201+
let (_state, _position) = Decoder::new(&self.buf, cursor).validate_response(state);
202+
match _state {
203203
DecodeState::Completed(resp) => return Ok(resp),
204204
DecodeState::ChangeState(_state) => {
205205
expected = 1;
206206
state = _state;
207-
cursor = decoder.position();
207+
cursor = _position;
208208
}
209209
DecodeState::Error(e) => return Err(Error::ProtocolError(e)),
210210
}

src/io/sync.rs

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,7 @@ use {
2828
error::{ClientResult, ConnectionSetupError, Error},
2929
protocol::{
3030
handshake::{ClientHandshake, ServerHandshake},
31-
state_init::{DecodeState, MRespState, PipelineResult, RState},
32-
Decoder,
31+
DecodeState, Decoder, MRespState, PipelineResult, RState,
3332
},
3433
query::Pipeline,
3534
response::{FromResponse, Response},
@@ -163,11 +162,12 @@ impl<C: Write + Read> TcpConnection<C> {
163162
return Err(Error::IoError(std::io::ErrorKind::ConnectionReset.into()));
164163
}
165164
self.buf.extend_from_slice(&buf[..n]);
166-
let mut decoder = Decoder::new(&self.buf, cursor);
167-
match decoder.validate_pipe(pipeline.query_count(), state) {
165+
let (_state, _position) =
166+
Decoder::new(&self.buf, cursor).validate_pipe(pipeline.query_count(), state);
167+
match _state {
168168
PipelineResult::Completed(r) => return Ok(r),
169169
PipelineResult::Pending(_state) => {
170-
cursor = decoder.position();
170+
cursor = _position;
171171
state = _state;
172172
}
173173
PipelineResult::Error(e) => return Err(e.into()),
@@ -189,15 +189,14 @@ impl<C: Write + Read> TcpConnection<C> {
189189
return Err(Error::IoError(std::io::ErrorKind::ConnectionReset.into()));
190190
}
191191
self.buf.extend_from_slice(&buf[..n]);
192-
let mut decoder = Decoder::new(&self.buf, cursor);
193-
match decoder.validate_response(state) {
194-
DecodeState::ChangeState(new_state) => {
195-
state = new_state;
196-
cursor = decoder.position();
197-
continue;
198-
}
192+
let (_state, _position) = Decoder::new(&self.buf, cursor).validate_response(state);
193+
match _state {
199194
DecodeState::Completed(resp) => return Ok(resp),
200-
DecodeState::Error(e) => return Err(e.into()),
195+
DecodeState::ChangeState(_state) => {
196+
state = _state;
197+
cursor = _position;
198+
}
199+
DecodeState::Error(e) => return Err(Error::ProtocolError(e)),
201200
}
202201
}
203202
}

0 commit comments

Comments
 (0)