From 6cd4addc1a272a521825a1a3ddb7274524f8d6f1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maxime=20=E2=80=9Cpep=E2=80=9D=20Buquet?= Date: Wed, 7 Jun 2023 16:45:01 +0200 Subject: [PATCH] parsers: Add with_payload/with_payloads helpers on Message MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Maxime “pep” Buquet --- parsers/src/message.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/parsers/src/message.rs b/parsers/src/message.rs index e03578f..c0621f8 100644 --- a/parsers/src/message.rs +++ b/parsers/src/message.rs @@ -154,6 +154,18 @@ impl Message { self } + /// Set a payload inside this message. + pub fn with_payload(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) -> Message { + self.payloads = payloads; + self + } + fn get_best<'a, T>( map: &'a BTreeMap, preferred_langs: Vec<&str>,