@@ -56,11 +56,11 @@ pub struct EvLoggedOut{
5656 #[ pyo3( get) ]
5757 on_connect : bool ,
5858 #[ pyo3( get) ]
59- reason : & ' static str ,
59+ reason : String ,
6060}
6161impl EvLoggedOut {
6262 pub fn new ( logout : WhatsAppLoggedOut ) -> Self {
63- Self { on_connect : logout. on_connect , reason : & connect_failure_reason_to_string ( & logout. reason ) }
63+ Self { on_connect : logout. on_connect , reason : connect_failure_reason_to_string ( & logout. reason ) }
6464 }
6565}
6666
@@ -94,7 +94,11 @@ pub struct EvPairError {
9494 #[ pyo3( get) ]
9595 error : String ,
9696}
97-
97+ impl EvPairError {
98+ pub fn new ( id : JID , lid : JID , business_name : String , platform : String , error : String ) -> Self {
99+ Self { id, lid, business_name, platform, error }
100+ }
101+ }
98102#[ pyclass]
99103pub struct EvPairingQrCode {
100104 #[ pyo3( get) ]
@@ -117,6 +121,12 @@ pub struct EvPairingCode {
117121 timeout : u64 ,
118122}
119123
124+ impl EvPairingCode {
125+ pub fn new ( code : String , timeout : u64 ) -> Self {
126+ Self { code, timeout }
127+ }
128+ }
129+
120130#[ pyclass]
121131pub struct EvQrScannedWithoutMultidevice ;
122132
@@ -125,7 +135,6 @@ pub struct EvQrScannedWithoutMultidevice;
125135pub struct EvClientOutDated ;
126136
127137#[ pyclass]
128- // #[derive(Clone)]
129138enum ReceiptType {
130139 Delivered ,
131140 Sender ,
@@ -352,23 +361,23 @@ impl EvMessage {
352361 }
353362}
354363
355- pub fn connect_failure_reason_to_string ( reason : & ConnectFailureReason ) -> & ' static str {
364+ pub fn connect_failure_reason_to_string ( reason : & ConnectFailureReason ) -> String {
356365 match reason {
357- ConnectFailureReason :: BadUserAgent => "BadUserAgent" ,
358- ConnectFailureReason :: LoggedOut => "LoggedOut" ,
359- ConnectFailureReason :: CatExpired => "CatExpired" ,
360- ConnectFailureReason :: CatInvalid => "CatInvalid" ,
361- ConnectFailureReason :: ClientOutdated => "ClientOutdated" ,
362- ConnectFailureReason :: ClientUnknown => "ClientUnknown" ,
363- ConnectFailureReason :: Generic => "Generic" ,
364- ConnectFailureReason :: TempBanned => "TempBanned" ,
365- ConnectFailureReason :: UnknownLogout => "Unknown" ,
366- ConnectFailureReason :: MainDeviceGone => "MainDeviceGone" ,
367- ConnectFailureReason :: NotFound => "NotFound" ,
368- ConnectFailureReason :: ServiceUnavailable => "ServiceUnavailable" ,
369- ConnectFailureReason :: InternalServerError => "InternalServerError" ,
370- ConnectFailureReason :: Experimental => "Experimental" ,
371- ConnectFailureReason :: Unknown ( _ ) => "Unknown" ,
366+ ConnectFailureReason :: BadUserAgent => "BadUserAgent" . into ( ) ,
367+ ConnectFailureReason :: LoggedOut => "LoggedOut" . into ( ) ,
368+ ConnectFailureReason :: CatExpired => "CatExpired" . into ( ) ,
369+ ConnectFailureReason :: CatInvalid => "CatInvalid" . into ( ) ,
370+ ConnectFailureReason :: ClientOutdated => "ClientOutdated" . into ( ) ,
371+ ConnectFailureReason :: ClientUnknown => "ClientUnknown" . into ( ) ,
372+ ConnectFailureReason :: Generic => "Generic" . into ( ) ,
373+ ConnectFailureReason :: TempBanned => "TempBanned" . into ( ) ,
374+ ConnectFailureReason :: UnknownLogout => "Unknown" . into ( ) ,
375+ ConnectFailureReason :: MainDeviceGone => "MainDeviceGone" . into ( ) ,
376+ ConnectFailureReason :: NotFound => "NotFound" . into ( ) ,
377+ ConnectFailureReason :: ServiceUnavailable => "ServiceUnavailable" . into ( ) ,
378+ ConnectFailureReason :: InternalServerError => "InternalServerError" . into ( ) ,
379+ ConnectFailureReason :: Experimental => "Experimental" . into ( ) ,
380+ ConnectFailureReason :: Unknown ( value ) => format ! ( "Unknown({})" , value ) . into ( ) ,
372381 }
373382}
374383
0 commit comments