@@ -98,7 +98,7 @@ impl From<PersistenceMode> for async_nats::jetstream::stream::PersistenceMode {
9898}
9999
100100#[ pyclass( from_py_object) ]
101- #[ derive( Clone , Debug , PartialEq , Default ) ]
101+ #[ derive( Clone , Debug , PartialEq , Eq , Default ) ]
102102pub struct ConsumerLimits {
103103 pub inactive_threshold : Duration ,
104104 pub max_ack_pending : i64 ,
@@ -107,7 +107,8 @@ pub struct ConsumerLimits {
107107#[ pymethods]
108108impl ConsumerLimits {
109109 #[ new]
110- pub fn __new__ ( inactive_threshold : Duration , max_ack_pending : i64 ) -> Self {
110+ #[ must_use]
111+ pub const fn __new__ ( inactive_threshold : Duration , max_ack_pending : i64 ) -> Self {
111112 Self {
112113 inactive_threshold,
113114 max_ack_pending,
@@ -135,7 +136,8 @@ pub struct Republish {
135136#[ pymethods]
136137impl Republish {
137138 #[ new]
138- pub fn __new__ ( source : String , destination : String , headers_only : bool ) -> Self {
139+ #[ must_use]
140+ pub const fn __new__ ( source : String , destination : String , headers_only : bool ) -> Self {
139141 Self {
140142 source,
141143 destination,
@@ -387,7 +389,7 @@ impl StreamConfig {
387389 allow_message_schedules=None ,
388390 allow_message_counter=None ,
389391 ) ) ]
390- pub fn __new__ (
392+ pub const fn __new__ (
391393 name : String ,
392394 subjects : Vec < String > ,
393395 max_bytes : Option < i64 > ,
@@ -430,12 +432,12 @@ impl StreamConfig {
430432 ) -> NatsrpyResult < Self > {
431433 Ok ( Self {
432434 name,
435+ subjects,
433436 max_bytes,
434437 max_messages,
435438 max_messages_per_subject,
436439 discard,
437440 discard_new_per_subject,
438- subjects,
439441 retention,
440442 max_consumers,
441443 max_age,
@@ -523,9 +525,9 @@ impl TryFrom<StreamConfig> for async_nats::jetstream::stream::Config {
523525
524526 // Values that require conversion between python -> rust types.
525527 conf. republish = value. republish . map ( Into :: into) ;
526- conf. storage = value. storage . map ( Into :: into) . unwrap_or ( conf . storage ) ;
527- conf. retention = value. retention . map ( Into :: into) . unwrap_or ( conf . retention ) ;
528- conf. discard = value. discard . map ( Into :: into) . unwrap_or ( conf . discard ) ;
528+ conf. storage = value. storage . map_or ( conf . storage , Into :: into) ;
529+ conf. retention = value. retention . map_or ( conf . retention , Into :: into) ;
530+ conf. discard = value. discard . map_or ( conf . discard , Into :: into) ;
529531 conf. mirror = value. mirror . map ( TryInto :: try_into) . transpose ( ) ?;
530532 conf. sources = value
531533 . sources
@@ -543,7 +545,7 @@ impl TryFrom<StreamConfig> for async_nats::jetstream::stream::Config {
543545 conf. persist_mode = value. persist_mode . map ( Into :: into) ;
544546 conf. pause_until = value
545547 . pause_until
546- . map ( |val| time:: OffsetDateTime :: from_unix_timestamp ( val ) )
548+ . map ( time:: OffsetDateTime :: from_unix_timestamp)
547549 . transpose ( ) ?;
548550
549551 Ok ( conf)
@@ -576,7 +578,7 @@ impl StreamMessage {
576578 time. minute ( ) ,
577579 time. second ( ) ,
578580 time. microsecond ( ) ,
579- Some ( tz_info. deref ( ) ) ,
581+ Some ( & * tz_info) ,
580582 ) ?;
581583 Ok ( Self {
582584 subject : msg. subject . to_string ( ) ,
@@ -608,6 +610,7 @@ pub struct Stream {
608610 stream : Arc < RwLock < async_nats:: jetstream:: stream:: Stream < async_nats:: jetstream:: stream:: Info > > > ,
609611}
610612impl Stream {
613+ #[ must_use]
611614 pub fn new (
612615 stream : async_nats:: jetstream:: stream:: Stream < async_nats:: jetstream:: stream:: Info > ,
613616 ) -> Self {
0 commit comments