Skip to content

Commit 6d47036

Browse files
committed
Remove v1 protocol support
1 parent cac69ec commit 6d47036

File tree

14 files changed

+57
-493
lines changed

14 files changed

+57
-493
lines changed

gel-db-protocol/src/protocol.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ message_group!(
3333
Execute,
3434
Sync,
3535
Terminate,
36-
Dump,
36+
Dump3,
3737
Restore,
3838
RestoreBlock,
3939
RestoreEof
@@ -294,16 +294,6 @@ struct AuthenticationSASLFinal<'a>: Message {
294294
sasl_data: Array<'a, u32, u8>,
295295
}
296296

297-
/// The `Dump` struct represents a dump message from the client.
298-
struct Dump<'a>: Message {
299-
/// Identifies the message as dump.
300-
mtype: u8 = '>',
301-
/// Length of message contents in bytes, including self.
302-
mlen: len,
303-
/// Message annotations.
304-
annotations: Array<'a, i16, Annotation<'a>>,
305-
}
306-
307297
/// The `Dump2` struct represents a dump message from the client.
308298
struct Dump2<'a>: Message {
309299
/// Identifies the message as dump.

gel-derive/src/shape.rs

Lines changed: 1 addition & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -52,45 +52,6 @@ pub fn derive_struct(
5252
};
5353
let fieldname = fields.iter().map(|f| f.name.clone()).collect::<Vec<_>>();
5454
let base_fields = fields.len();
55-
let type_id_block = Some(quote! {
56-
if #decoder.has_implicit_tid {
57-
#elements.skip_element()?;
58-
}
59-
});
60-
let type_name_block = Some(quote! {
61-
if #decoder.has_implicit_tname {
62-
#elements.skip_element()?;
63-
}
64-
});
65-
let id_block = Some(quote! {
66-
if #decoder.has_implicit_id {
67-
#elements.skip_element()?;
68-
}
69-
});
70-
let type_id_check = Some(quote! {
71-
if ctx.has_implicit_tid {
72-
if(!shape.elements[idx].flag_implicit) {
73-
return ::std::result::Result::Err(ctx.expected("implicit __tid__"));
74-
}
75-
idx += 1;
76-
}
77-
});
78-
let type_name_check = Some(quote! {
79-
if ctx.has_implicit_tname {
80-
if(!shape.elements[idx].flag_implicit) {
81-
return ::std::result::Result::Err(ctx.expected("implicit __tname__"));
82-
}
83-
idx += 1;
84-
}
85-
});
86-
let id_check = Some(quote! {
87-
if ctx.has_implicit_id {
88-
if(!shape.elements[idx].flag_implicit) {
89-
return ::std::result::Result::Err(ctx.expected("implicit id"));
90-
}
91-
idx += 1;
92-
}
93-
});
9455
let field_decoders = fields
9556
.iter()
9657
.enumerate()
@@ -189,17 +150,11 @@ pub fn derive_struct(
189150
(#order, #sub_args): &Self::Args,
190151
#buf: &[u8]
191152
) -> ::std::result::Result<Self, #gel_protocol::errors::DecodeError> {
192-
let #nfields = #base_fields
193-
+ if #decoder.has_implicit_id { 1 } else { 0 }
194-
+ if #decoder.has_implicit_tid { 1 } else { 0 }
195-
+ if #decoder.has_implicit_tname { 1 } else { 0 };
153+
let #nfields = #base_fields;
196154
let mut #elements =
197155
#gel_protocol::serialization::decode::DecodeTupleLike
198156
::new_object(#buf, #nfields)?;
199157

200-
#type_id_block
201-
#type_name_block
202-
#id_block
203158
let fields = #elements.read_n(#field_count)?;
204159
#field_decoders
205160
::std::result::Result::Ok(#name {
@@ -224,9 +179,6 @@ pub fn derive_struct(
224179

225180
// TODO(tailhook) cache shape.id somewhere
226181
let mut idx = 0;
227-
#type_id_check
228-
#type_name_check
229-
#id_check
230182
if(shape.elements.len() != #field_count) {
231183
return ::std::result::Result::Err(ctx.field_number(
232184
#field_count, shape.elements.len())

gel-derive/tests/json.rs

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,22 +20,11 @@ struct JsonRow {
2020
field2: u32,
2121
}
2222

23-
fn old_decoder() -> Decoder {
24-
let mut dec = Decoder::default();
25-
dec.has_implicit_id = true;
26-
dec.has_implicit_tid = true;
27-
dec
28-
}
29-
3023
#[test]
3124
fn json_field() {
32-
let data = b"\0\0\0\x04\0\0\x0b\x86\0\0\0\x10\xf2R\
33-
\x04I\xd7\x04\x11\xea\xaeX\xcf\xdf\xf6\xd0Q\xac\
34-
\0\0\x0b\x86\0\0\0\x10\xf2\xe6F9\xd7\x04\x11\xea\
35-
\xa0<\x83\x9f\xd9\xbd\x88\x94\0\0\0\x19\
36-
\0\0\0\x02id\0\0\x0e\xda\0\0\0\x10\x01{\"field1\": 123}";
25+
let data = b"\0\0\0\x02\0\0\0\x19\0\0\0\x02id\0\0\x0e\xda\0\0\0\x10\x01{\"field1\": 123}";
3726
let order = (vec![0_usize, 1], ((), ()));
38-
let res = ShapeWithJson::decode(&old_decoder(), &order, data);
27+
let res = ShapeWithJson::decode(&Decoder::default(), &order, data);
3928
assert_eq!(
4029
res.unwrap(),
4130
ShapeWithJson {
@@ -48,6 +37,6 @@ fn json_field() {
4837
#[test]
4938
fn json_row() {
5039
let data = b"\x01{\"field2\": 234}";
51-
let res = JsonRow::decode(&old_decoder(), &(), data);
40+
let res = JsonRow::decode(&Decoder::default(), &(), data);
5241
assert_eq!(res.unwrap(), JsonRow { field2: 234 });
5342
}

gel-derive/tests/list_scalar_types.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,6 @@ struct ScalarType {
88
kind: String,
99
}
1010

11-
fn old_decoder() -> Decoder {
12-
let mut dec = Decoder::default();
13-
dec.has_implicit_id = true;
14-
dec.has_implicit_tid = true;
15-
dec
16-
}
17-
1811
#[test]
1912
fn decode_new() {
2013
let data = b"\0\0\0\x03\0\0\0\x19\0\0\0\x0fcal::local_date\
@@ -40,7 +33,7 @@ fn decode_old() {
4033
\x01\x0c\0\0\0\x19\0\0\0\x0fcal::local_date\
4134
\0\0\0\x19\0\0\0\x0estd::anyscalar\0\0\0\x19\0\0\0\x06normal";
4235
let order = (vec![0, 1, 2], ((), (), ()));
43-
let res = ScalarType::decode(&old_decoder(), &order, data);
36+
let res = ScalarType::decode(&Decoder::default(), &order, data);
4437
assert_eq!(
4538
res.unwrap(),
4639
ScalarType {

0 commit comments

Comments
 (0)