11use std:: io:: Write ;
22
33use crate :: FieldType ;
4+ use crate :: HardCodedFixFieldDefinition ;
45use crate :: builder:: SOH ;
56use crate :: encoder:: Encode ;
67use crate :: error:: EncodingResult ;
78use crate :: field_map:: { Field , FieldMap } ;
89use crate :: parts:: { Body , Header , Part , RepeatingGroup , Trailer } ;
9- use crate :: { HardCodedFixFieldDefinition , fix44 } ;
10+ use crate :: session_fields :: { BEGIN_STRING , BODY_LENGTH , CHECK_SUM , MSG_TYPE } ;
1011use hotfix_dictionary:: { FieldLocation , IsFieldDefinition } ;
1112
1213pub struct Message {
@@ -22,8 +23,8 @@ impl Message {
2223 body : Body :: default ( ) ,
2324 trailer : Trailer :: default ( ) ,
2425 } ;
25- msg. set ( fix44 :: BEGIN_STRING , begin_string) ;
26- msg. set ( fix44 :: MSG_TYPE , message_type) ;
26+ msg. set ( BEGIN_STRING , begin_string) ;
27+ msg. set ( MSG_TYPE , message_type) ;
2728
2829 msg
2930 }
@@ -39,18 +40,14 @@ impl Message {
3940 pub fn encode ( & mut self , config : & Config ) -> EncodingResult < Vec < u8 > > {
4041 let mut buffer = Vec :: new ( ) ;
4142
42- self . trailer . pop ( fix44 :: CHECK_SUM ) ;
43+ self . trailer . pop ( CHECK_SUM ) ;
4344 let body_length = self . header . calculate_length ( )
4445 + self . body . calculate_length ( )
4546 + self . trailer . calculate_length ( ) ;
46- self . set ( fix44 :: BODY_LENGTH , format ! ( "{body_length}" ) . as_str ( ) ) ;
47+ self . set ( BODY_LENGTH , format ! ( "{body_length}" ) . as_str ( ) ) ;
4748 let check_sum_start = buffer. len ( ) ;
4849
49- let starting_fields = vec ! [
50- fix44:: BEGIN_STRING . tag( ) ,
51- fix44:: BODY_LENGTH . tag( ) ,
52- fix44:: MSG_TYPE . tag( ) ,
53- ] ;
50+ let starting_fields = vec ! [ BEGIN_STRING . tag( ) , BODY_LENGTH . tag( ) , MSG_TYPE . tag( ) ] ;
5451 self . header
5552 . fields
5653 . write ( config, & mut buffer, & starting_fields) ?;
@@ -61,7 +58,7 @@ impl Message {
6158 . iter ( )
6259 . fold ( 0u8 , |acc, & x| acc. wrapping_add ( x) ) ;
6360 let checksum_value = format ! ( "{checksum:03}" ) ;
64- self . set ( fix44 :: CHECK_SUM , checksum_value. as_str ( ) ) ;
61+ self . set ( CHECK_SUM , checksum_value. as_str ( ) ) ;
6562 buffer. write_all ( b"10=" ) ?;
6663 buffer. write_all ( checksum_value. as_bytes ( ) ) ?;
6764 buffer. push ( config. separator ) ;
0 commit comments