@@ -23,6 +23,7 @@ mod bolt5x4;
2323mod bolt5x6;
2424mod bolt5x7;
2525mod bolt5x8;
26+ mod bolt6x0;
2627mod bolt_handler;
2728mod bolt_state;
2829mod chunk;
@@ -64,6 +65,7 @@ use bolt5x4::{Bolt5x4, Bolt5x4StructTranslator};
6465use bolt5x6:: { Bolt5x6 , Bolt5x6StructTranslator } ;
6566use bolt5x7:: { Bolt5x7 , Bolt5x7StructTranslator } ;
6667use bolt5x8:: { Bolt5x8 , Bolt5x8StructTranslator } ;
68+ use bolt6x0:: { Bolt6x0 , Bolt6x0StructTranslator } ;
6769use bolt_common:: ServerAwareBoltVersion ;
6870use bolt_handler:: {
6971 BeginHandler , CommitHandler , DiscardHandler , GoodbyeHandler , HandleResponseHandler ,
@@ -203,6 +205,7 @@ pub(crate) struct Bolt<RW: Read + Write> {
203205 protocol : BoltProtocol ,
204206}
205207
208+ // [bolt-version-bump] search tag when changing bolt version support
206209impl < RW : Read + Write > Bolt < RW > {
207210 fn new (
208211 version : ( u8 , u8 ) ,
@@ -211,44 +214,39 @@ impl<RW: Read + Write> Bolt<RW> {
211214 local_port : Option < u16 > ,
212215 address : Arc < Address > ,
213216 ) -> Self {
214- let ( protocol_version, protocol) = match version {
215- ( 5 , 8 ) => (
216- ServerAwareBoltVersion :: V5x8 ,
217- Bolt5x8 :: < Bolt5x0StructTranslator > :: default ( ) . into ( ) ,
218- ) ,
219- ( 5 , 7 ) => (
220- ServerAwareBoltVersion :: V5x7 ,
221- Bolt5x7 :: < Bolt5x0StructTranslator > :: default ( ) . into ( ) ,
222- ) ,
223- ( 5 , 6 ) => (
224- ServerAwareBoltVersion :: V5x6 ,
225- Bolt5x6 :: < Bolt5x0StructTranslator > :: default ( ) . into ( ) ,
226- ) ,
227- ( 5 , 4 ) => (
228- ServerAwareBoltVersion :: V5x4 ,
229- Bolt5x4 :: < Bolt5x0StructTranslator > :: default ( ) . into ( ) ,
230- ) ,
231- ( 5 , 3 ) => (
232- ServerAwareBoltVersion :: V5x3 ,
233- Bolt5x3 :: < Bolt5x0StructTranslator > :: default ( ) . into ( ) ,
234- ) ,
235- ( 5 , 2 ) => (
236- ServerAwareBoltVersion :: V5x2 ,
237- Bolt5x2 :: < Bolt5x0StructTranslator > :: default ( ) . into ( ) ,
238- ) ,
239- ( 5 , 1 ) => (
240- ServerAwareBoltVersion :: V5x1 ,
241- Bolt5x1 :: < Bolt5x0StructTranslator > :: default ( ) . into ( ) ,
242- ) ,
243- ( 5 , 0 ) => (
244- ServerAwareBoltVersion :: V5x0 ,
245- Bolt5x0 :: < Bolt5x0StructTranslator > :: default ( ) . into ( ) ,
246- ) ,
247- ( 4 , 4 ) => (
248- ServerAwareBoltVersion :: V4x4 ,
249- Bolt4x4 :: < Bolt4x4StructTranslator > :: default ( ) . into ( ) ,
250- ) ,
251- _ => panic ! ( "implement protocol for version {version:?}" ) ,
217+ let protocol_version = ServerAwareBoltVersion :: parse ( version. 0 , version. 1 )
218+ . unwrap_or_else ( || panic ! ( "implement protocol for version {version:?}" ) ) ;
219+ let protocol = match protocol_version {
220+ ServerAwareBoltVersion :: V6x0 => {
221+ Bolt6x0 :: < Bolt6x0StructTranslator > :: new ( protocol_version) . into ( )
222+ }
223+ ServerAwareBoltVersion :: V5x8 => {
224+ Bolt5x8 :: < Bolt5x8StructTranslator > :: new ( protocol_version) . into ( )
225+ }
226+ ServerAwareBoltVersion :: V5x7 => {
227+ Bolt5x7 :: < Bolt5x7StructTranslator > :: new ( protocol_version) . into ( )
228+ }
229+ ServerAwareBoltVersion :: V5x6 => {
230+ Bolt5x6 :: < Bolt5x6StructTranslator > :: new ( protocol_version) . into ( )
231+ }
232+ ServerAwareBoltVersion :: V5x4 => {
233+ Bolt5x4 :: < Bolt5x4StructTranslator > :: new ( protocol_version) . into ( )
234+ }
235+ ServerAwareBoltVersion :: V5x3 => {
236+ Bolt5x3 :: < Bolt5x3StructTranslator > :: new ( protocol_version) . into ( )
237+ }
238+ ServerAwareBoltVersion :: V5x2 => {
239+ Bolt5x2 :: < Bolt5x2StructTranslator > :: new ( protocol_version) . into ( )
240+ }
241+ ServerAwareBoltVersion :: V5x1 => {
242+ Bolt5x1 :: < Bolt5x1StructTranslator > :: new ( protocol_version) . into ( )
243+ }
244+ ServerAwareBoltVersion :: V5x0 => {
245+ Bolt5x0 :: < Bolt5x0StructTranslator > :: new ( protocol_version) . into ( )
246+ }
247+ ServerAwareBoltVersion :: V4x4 => {
248+ Bolt4x4 :: < Bolt4x4StructTranslator > :: new ( protocol_version) . into ( )
249+ }
252250 } ;
253251 let data = BoltData :: new (
254252 version,
@@ -505,6 +503,7 @@ enum BoltProtocol {
505503 V5x6 ( Bolt5x6 < Bolt5x6StructTranslator > ) ,
506504 V5x7 ( Bolt5x7 < Bolt5x7StructTranslator > ) ,
507505 V5x8 ( Bolt5x8 < Bolt5x8StructTranslator > ) ,
506+ V6x0 ( Bolt6x0 < Bolt6x0StructTranslator > ) ,
508507}
509508
510509#[ derive( Debug , Copy , Clone , Ord , PartialOrd , Eq , PartialEq ) ]
@@ -783,7 +782,9 @@ impl AuthResetHandle {
783782 }
784783}
785784
786- pub ( crate ) trait BoltStructTranslator : Debug + Default {
785+ pub ( crate ) trait BoltStructTranslator : Debug {
786+ fn new ( bolt_version : ServerAwareBoltVersion ) -> Self ;
787+
787788 fn serialize < S : PackStreamSerializer > (
788789 & self ,
789790 serializer : & mut S ,
@@ -794,6 +795,10 @@ pub(crate) trait BoltStructTranslator: Debug + Default {
794795}
795796
796797impl < T : BoltStructTranslator > BoltStructTranslator for Arc < AtomicRefCell < T > > {
798+ fn new ( bolt_version : ServerAwareBoltVersion ) -> Self {
799+ Arc :: new ( AtomicRefCell :: new ( T :: new ( bolt_version) ) )
800+ }
801+
797802 fn serialize < S : PackStreamSerializer > (
798803 & self ,
799804 serializer : & mut S ,
0 commit comments