parsers: Add with_payload/with_payloads helpers on Message

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-06-07 16:45:01 +02:00
parent c8dcf5e7a7
commit 6cd4addc1a

View file

@ -154,6 +154,18 @@ impl Message {
self
}
/// Set a payload inside this message.
pub fn with_payload<P: MessagePayload>(mut self, payload: P) -> Message {
self.payloads.push(payload.into());
self
}
/// Set the payloads of this message.
pub fn with_payloads(mut self, payloads: Vec<Element>) -> Message {
self.payloads = payloads;
self
}
fn get_best<'a, T>(
map: &'a BTreeMap<Lang, T>,
preferred_langs: Vec<&str>,