@@ -57,17 +57,12 @@ use serde::Serialize;
5757pub struct Message {
5858 body : Part ,
5959 parts : Vec < Part > ,
60- is_illegal : bool ,
6160}
6261
6362impl Message {
6463 /// Returns a new message with the given body and parts.
6564 pub fn from_body_and_parts ( body : Part , parts : Vec < Part > ) -> Self {
66- Self {
67- body,
68- parts,
69- is_illegal : false ,
70- }
65+ Self { body, parts }
7166 }
7267
7368 /// The body of the message.
@@ -118,17 +113,8 @@ impl Message {
118113 /// each part
119114 /// ```
120115 pub fn framed ( self ) -> Frame {
121- let is_illegal = self . is_illegal ;
122116 let ( body, parts) = self . into_inner ( ) ;
123117
124- if is_illegal {
125- assert ! ( parts. is_empty( ) , "illegal illegal message" ) ;
126- return Frame :: from_buffers ( vec ! [
127- Bytes :: from_owner( u64 :: MAX . to_be_bytes( ) ) ,
128- body. into_inner( ) ,
129- ] ) ;
130- }
131-
132118 let mut buffers = Vec :: with_capacity ( 2 + 2 * parts. len ( ) ) ;
133119
134120 let body = body. into_inner ( ) ;
@@ -150,14 +136,6 @@ impl Message {
150136 return Err ( std:: io:: ErrorKind :: UnexpectedEof . into ( ) ) ;
151137 }
152138 let body_len = buf. get_u64 ( ) ;
153- if body_len == u64:: MAX {
154- return Ok ( Self {
155- body : buf. into ( ) ,
156- parts : vec ! [ ] ,
157- is_illegal : true ,
158- } ) ;
159- }
160-
161139 let body = buf. split_to ( body_len as usize ) ;
162140 let mut parts = Vec :: new ( ) ;
163141 while !buf. is_empty ( ) {
@@ -166,7 +144,6 @@ impl Message {
166144 Ok ( Self {
167145 body : body. into ( ) ,
168146 parts,
169- is_illegal : false ,
170147 } )
171148 }
172149
@@ -180,10 +157,6 @@ impl Message {
180157 }
181158 Ok ( buf. split_to ( at) )
182159 }
183-
184- pub fn is_illegal ( & self ) -> bool {
185- self . is_illegal
186- }
187160}
188161
189162/// An encoded [`Message`] frame. Implements [`bytes::Buf`],
@@ -325,7 +298,6 @@ pub fn serialize_bincode<S: ?Sized + serde::Serialize>(
325298 Ok ( Message {
326299 body : Part ( buffer. into_inner ( ) . freeze ( ) ) ,
327300 parts : serializer. into_parts ( ) ,
328- is_illegal : false ,
329301 } )
330302}
331303
@@ -335,14 +307,6 @@ pub fn deserialize_bincode<T>(message: Message) -> Result<T, bincode::Error>
335307where
336308 T : serde:: de:: DeserializeOwned ,
337309{
338- if message. is_illegal {
339- let ( body, parts) = message. into_inner ( ) ;
340- if !parts. is_empty ( ) {
341- return Err ( bincode:: ErrorKind :: Custom ( "illegal illegal message" . to_string ( ) ) . into ( ) ) ;
342- }
343- return bincode:: deserialize_from ( body. into_inner ( ) . reader ( ) ) ;
344- }
345-
346310 let ( body, parts) = message. into_inner ( ) ;
347311 let mut deserializer = part:: BincodeDeserializer :: new (
348312 bincode:: Deserializer :: with_reader ( body. into_inner ( ) . reader ( ) , options ( ) ) ,
@@ -354,22 +318,6 @@ where
354318 Ok ( value)
355319}
356320
357- /// Serializes the provided value into an "illegal" Message that acts as an ordinary
358- /// bincode-encoded buffer (bypassing multipart extraction and encoding). This is
359- /// only used to support hyperactor's transition to multipart encoding, and will be
360- /// removed after it is complete.
361- ///
362- /// **YOU SHOULD NOT USE THIS**
363- pub fn serialize_illegal_bincode < S : ?Sized + serde:: Serialize > (
364- value : & S ,
365- ) -> Result < Message , bincode:: Error > {
366- Ok ( Message {
367- body : Part :: from ( bincode:: serialize ( value) ?) ,
368- parts : vec ! [ ] ,
369- is_illegal : true ,
370- } )
371- }
372-
373321/// Construct the set of options used by the specialized serializer and deserializer.
374322fn options ( ) -> part:: BincodeOptionsType {
375323 bincode:: DefaultOptions :: new ( )
@@ -412,16 +360,6 @@ mod tests {
412360 let bincode_serialized = bincode:: serialize ( & value) . unwrap ( ) ;
413361 let bincode_deserialized = bincode:: deserialize ( & bincode_serialized) . unwrap ( ) ;
414362 assert_eq ! ( value, bincode_deserialized) ;
415-
416- // Illegal encoding:
417- let bincode_illegal = serialize_illegal_bincode ( & value) . unwrap ( ) ;
418- let mut bincode_illegal_framed = bincode_illegal. clone ( ) . framed ( ) ;
419- let bincode_illegal_framed =
420- bincode_illegal_framed. copy_to_bytes ( bincode_illegal_framed. remaining ( ) ) ;
421- let bincode_illegal_unframed = Message :: from_framed ( bincode_illegal_framed) . unwrap ( ) ;
422- let bincode_illegal_deserialized_value =
423- deserialize_bincode ( bincode_illegal_unframed. clone ( ) ) . unwrap ( ) ;
424- assert_eq ! ( value, bincode_illegal_deserialized_value) ;
425363 }
426364
427365 #[ test]
@@ -507,7 +445,6 @@ mod tests {
507445 let message = Message {
508446 body : Part :: from ( "hello" ) ,
509447 parts : vec ! [ Part :: from( "world" ) ] ,
510- is_illegal : false ,
511448 } ;
512449 let err = deserialize_bincode :: < String > ( message) . unwrap_err ( ) ;
513450
@@ -565,7 +502,6 @@ mod tests {
565502 Part :: from( "xyz" ) ,
566503 Part :: from( "xyzd" ) ,
567504 ] ,
568- is_illegal : false ,
569505 } ;
570506
571507 let mut framed = message. clone ( ) . framed ( ) ;
0 commit comments