Skip to main content

mux_media/
traits.rs

1pub(crate) mod lazy_fields;
2
3use crate::Result;
4
5/// Provides a delayed initialization for expensive operations.
6pub trait TryFinalizeInit {
7    /// Finalizes initialization.
8    fn try_finalize_init(&mut self) -> Result<()>;
9}
10
11/// Converts a value to JSON-compatible arguments.
12pub trait ToJsonArgs {
13    /// Appends arguments to the given `args` vector.
14    fn append_json_args(&self, args: &mut Vec<String>);
15
16    /// Returns arguments.
17    fn to_json_args(&self) -> Vec<String> {
18        let mut args = Vec::new();
19        self.append_json_args(&mut args);
20        args
21    }
22}
23
24/// Associates a field with the marker type `F`.
25pub trait Field<F> {
26    type FieldType;
27
28    /// Returns a reference to the field value.
29    fn field(&self) -> &Self::FieldType;
30}