Separate Labelled from LabelsLoader
This commit is contained in:
parent
0d8f88839e
commit
b1abce5a24
@ -5,7 +5,7 @@ use std::{collections::HashMap, iter::IntoIterator, sync::Arc};
|
||||
use crate::{
|
||||
app::{error::Error, message::Message, view},
|
||||
daemon::{
|
||||
model::{LabelItem, Labelled},
|
||||
model::{LabelItem, Labelled, LabelsLoader},
|
||||
Daemon,
|
||||
},
|
||||
};
|
||||
|
||||
@ -333,7 +333,7 @@ pub trait Daemon: Debug {
|
||||
}
|
||||
}
|
||||
|
||||
async fn load_labels<T: model::Labelled, D: Daemon + ?Sized>(
|
||||
async fn load_labels<T: model::Labelled + model::LabelsLoader, D: Daemon + ?Sized>(
|
||||
daemon: &D,
|
||||
targets: &mut Vec<T>,
|
||||
) -> Result<(), DaemonError> {
|
||||
|
||||
@ -447,6 +447,16 @@ impl Labelled for HistoryTransaction {
|
||||
pub trait Labelled {
|
||||
fn labelled(&self) -> Vec<LabelItem>;
|
||||
fn labels(&mut self) -> &mut HashMap<String, String>;
|
||||
}
|
||||
|
||||
pub trait LabelsLoader {
|
||||
fn load_labels(&mut self, new_labels: &HashMap<String, Option<String>>);
|
||||
}
|
||||
|
||||
impl<T: ?Sized> LabelsLoader for T
|
||||
where
|
||||
T: Labelled,
|
||||
{
|
||||
fn load_labels(&mut self, new_labels: &HashMap<String, Option<String>>) {
|
||||
let items = self.labelled();
|
||||
let labels = self.labels();
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user