make the data: Vec<T> mutable, then reverse the vector
so it can be used as a stack, and then use the ::pop()
method to retrieve the item.
This also avoid the constrain for Clone on T.
The state machines are not send and the code is sequnecial.
We only need `&mut machine` refference to pass to `take_mut::take`
to change the state of the machine. In 2/3 cases we can even use
`.get_mut()` method and even avoid the dynamic borrow checks at
runtime. For the `TitleMachine` The only thing that will hold
a refference to it after initialization will be the play_button
callback. So it's justifiable to use `RefCell` insetead of a `Mutex`.
`DateMachine` and `DurationMachine` are only mutated during initialization
and thus do not need shared ownership.
`TitleMachine` is only mutated during initialization and after that only
the callback will keep holding a referrence to it. The `EpisodeWidget`s
get dropped after initialization. So it's justifiable to use `Rc<Mutex<T>>`
instead of `Arc`.
Add a ButtonState Machine which represents the state of total_size
label, play button, and download button. Also implemented the
update/determine_state function for ButtonState.
Also implemented required generic functions for MediaMachine<X,Y,Z>
that convert it to the desired state.
Currently it's required that you take mut self in order to manipulate
the internal state machines. This would not allow passing an Arc/Rc to
a callback since A/Rc<T> only derefs to &T and not T.
The take_mut crate allows the retrieval of ownership if you have a &mut refference
and as long you return T again. So Arc<Mutex<Machine> could work with
callbacks and embed Nested state machies without copying.
Before we were avoiding reloading the widget in view by
directly dimming the title label. Now instead we reload
the whole widget since I can't figure out a way to have
multiple Owneded refferences of the same state machine.
Before if a feed had reported a number between 1 and 60, a label 0 min
would be set.
This fixes that, while also using chrono::Duration for parsing minutes.