@@ -137,12 +137,8 @@ pub struct StreamConfig {
137137 /// Timestamping configuration.
138138 pub timestamping : Option < TimestampingConfig > ,
139139 #[ arg( long, help( "Example: 1d, 1w, 1y" ) ) ]
140- /// Delete-on-empty configuration.
141- #[ serde(
142- skip_serializing_if = "Option::is_none" ,
143- serialize_with = "serialize_humantime_duration"
144- ) ]
145- pub delete_on_empty_min_age : Option < humantime:: Duration > ,
140+ /// Delete-on-empty configuration.
141+ pub delete_on_empty_min_age : Option < DeleteOnEmptyConfig > ,
146142}
147143
148144#[ derive( ValueEnum , Debug , Clone , Serialize ) ]
@@ -186,11 +182,11 @@ impl From<&str> for RetentionPolicy {
186182 }
187183}
188184#[ derive( Clone , Debug , Serialize ) ]
189- pub struct DeleteOnEmpty {
185+ pub struct DeleteOnEmptyConfig {
190186 pub min_age : Duration ,
191187}
192188
193- impl FromStr for DeleteOnEmpty {
189+ impl FromStr for DeleteOnEmptyConfig {
194190 type Err = humantime:: DurationError ;
195191
196192 fn from_str ( s : & str ) -> Result < Self , Self :: Err > {
@@ -199,15 +195,15 @@ impl FromStr for DeleteOnEmpty {
199195 }
200196}
201197
202- impl From < DeleteOnEmpty > for s2:: types:: DeleteOnEmpty {
203- fn from ( value : DeleteOnEmpty ) -> Self {
198+ impl From < DeleteOnEmptyConfig > for s2:: types:: DeleteOnEmpty {
199+ fn from ( value : DeleteOnEmptyConfig ) -> Self {
204200 s2:: types:: DeleteOnEmpty {
205201 min_age : value. min_age ,
206202 }
207203 }
208204}
209205
210- impl From < s2:: types:: DeleteOnEmpty > for DeleteOnEmpty {
206+ impl From < s2:: types:: DeleteOnEmpty > for DeleteOnEmptyConfig {
211207 fn from ( value : s2:: types:: DeleteOnEmpty ) -> Self {
212208 Self {
213209 min_age : value. min_age ,
@@ -242,7 +238,9 @@ impl From<StreamConfig> for s2::types::StreamConfig {
242238
243239 let delete_on_empty = config
244240 . delete_on_empty_min_age
245- . map ( |age| s2:: types:: DeleteOnEmpty { min_age : * age } ) ;
241+ . map ( |age| s2:: types:: DeleteOnEmpty {
242+ min_age : age. min_age ,
243+ } ) ;
246244
247245 let mut stream_config = s2:: types:: StreamConfig :: new ( ) ;
248246 if let Some ( storage_class) = storage_class {
@@ -349,9 +347,9 @@ impl From<s2::types::StreamConfig> for StreamConfig {
349347 storage_class : config. storage_class . map ( Into :: into) ,
350348 retention_policy : config. retention_policy . map ( Into :: into) ,
351349 timestamping : config. timestamping . map ( Into :: into) ,
352- delete_on_empty_min_age : config
353- . delete_on_empty
354- . map ( |age| humantime :: Duration :: from ( age . min_age ) ) ,
350+ delete_on_empty_min_age : config. delete_on_empty . map ( |age| DeleteOnEmptyConfig {
351+ min_age : age . min_age ,
352+ } ) ,
355353 }
356354 }
357355}
@@ -722,22 +720,6 @@ impl FromStr for Operation {
722720 }
723721}
724722
725- fn serialize_humantime_duration < S > (
726- duration : & Option < humantime:: Duration > ,
727- serializer : S ,
728- ) -> Result < S :: Ok , S :: Error >
729- where
730- S : serde:: Serializer ,
731- {
732- match duration {
733- Some ( d) => {
734- let std_duration: std:: time:: Duration = ( * d) . into ( ) ;
735- std_duration. serialize ( serializer)
736- }
737- None => serializer. serialize_none ( ) ,
738- }
739- }
740-
741723#[ cfg( test) ]
742724mod tests {
743725 use crate :: { error:: S2UriParseError , types:: S2BasinAndStreamUri } ;
0 commit comments