@@ -28,7 +28,12 @@ pub struct Response {
2828 pub current_updates : HashMap < String , CurrentUpdate > ,
2929}
3030
31+ /// Information about a current update.
32+ ///
33+ /// To create an instance of this type, first create a `CurrentUpdateInit` and convert it via
34+ /// `CurrentUpdate::from` / `.into()`.
3135#[ derive( Serialize , Deserialize , PartialEq , Clone , Debug ) ]
36+ #[ cfg_attr( not( ruma_unstable_exhaustive_types) , non_exhaustive) ]
3237pub struct CurrentUpdate {
3338 /// Name of the update.
3439 pub name : String ,
@@ -43,6 +48,33 @@ pub struct CurrentUpdate {
4348 pub average_items_per_ms : f64 ,
4449}
4550
51+ /// Initial set of fields of [`CurrentUpdate`].
52+ ///
53+ /// This struct will not be updated even if additional fields are added to `CurrentUpdate`.
54+ #[ derive( Debug ) ]
55+ #[ allow( clippy:: exhaustive_structs) ]
56+ pub struct CurrentUpdateInit {
57+ /// Name of the update.
58+ pub name : String ,
59+
60+ /// Total number of processed "items".
61+ pub total_item_count : u64 ,
62+
63+ /// Runtime of background process, not including sleeping time.
64+ pub total_duration_ms : f64 ,
65+
66+ /// Items processed per millisecond based on an exponential average.
67+ pub average_items_per_ms : f64 ,
68+ }
69+
70+ impl From < CurrentUpdateInit > for CurrentUpdate {
71+ fn from ( value : CurrentUpdateInit ) -> Self {
72+ let CurrentUpdateInit { name, total_item_count, total_duration_ms, average_items_per_ms } =
73+ value;
74+ Self { name, total_item_count, total_duration_ms, average_items_per_ms }
75+ }
76+ }
77+
4678impl Request {
4779 /// Creates an empty `Request`.
4880 pub fn new ( ) -> Self {
0 commit comments