mirror of
https://gitlab.com/xmpp-rs/xmpp-rs.git
synced 2024-07-12 22:21:53 +00:00
stanza_error: Add a constructor.
This commit is contained in:
parent
ab28824b1a
commit
017fb0fbd1
1 changed files with 20 additions and 0 deletions
|
@ -215,6 +215,26 @@ pub struct StanzaError {
|
|||
impl MessagePayload for StanzaError {}
|
||||
impl PresencePayload for StanzaError {}
|
||||
|
||||
impl StanzaError {
|
||||
/// Create a new `<error/>` with the according content.
|
||||
pub fn new<L, T>(type_: ErrorType, defined_condition: DefinedCondition, lang: L, text: T) -> StanzaError
|
||||
where L: Into<Lang>,
|
||||
T: Into<String>,
|
||||
{
|
||||
StanzaError {
|
||||
type_,
|
||||
by: None,
|
||||
defined_condition,
|
||||
texts: {
|
||||
let mut map = BTreeMap::new();
|
||||
map.insert(lang.into(), text.into());
|
||||
map
|
||||
},
|
||||
other: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl TryFrom<Element> for StanzaError {
|
||||
type Err = Error;
|
||||
|
||||
|
|
Loading…
Reference in a new issue