presence: Add with_ helpers to build a Presence

Maxime “pep” Buquet created

Change summary

src/presence.rs | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)

Detailed changes

src/presence.rs 🔗

@@ -211,6 +211,36 @@ impl Presence {
             payloads: vec!(),
         }
     }
+
+    pub fn with_from(mut self, from: Option<Jid>) -> Presence {
+        self.from = from;
+        self
+    }
+
+    pub fn with_to(mut self, to: Option<Jid>) -> Presence {
+        self.to = to;
+        self
+    }
+
+    pub fn with_id(mut self, id: Option<String>) -> Presence {
+        self.id = id;
+        self
+    }
+
+    pub fn with_show(mut self, show: Show) -> Presence {
+        self.show = show;
+        self
+    }
+
+    pub fn with_priority(mut self, priority: i8) -> Presence {
+        self.priority = priority;
+        self
+    }
+
+    pub fn with_payloads(mut self, payloads: Vec<Element>) -> Presence {
+        self.payloads = payloads;
+        self
+    }
 }
 
 impl TryFrom<Element> for Presence {