2019-09-07 14:32:03 +00:00
|
|
|
// Copyright (c) 2019 Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
|
|
|
|
//
|
|
|
|
// This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
// License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
|
|
|
|
|
2024-07-09 15:01:42 +00:00
|
|
|
use xso::{AsXml, FromXml};
|
2019-09-07 14:32:03 +00:00
|
|
|
|
2024-06-21 15:54:12 +00:00
|
|
|
use crate::ns;
|
2019-09-07 14:32:03 +00:00
|
|
|
|
2024-06-21 15:54:12 +00:00
|
|
|
/// Stream:feature sent by the server to advertise it supports CSI.
|
2024-07-09 15:01:42 +00:00
|
|
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
2024-06-21 15:54:12 +00:00
|
|
|
#[xml(namespace = ns::CSI, name = "csi")]
|
|
|
|
pub struct Feature;
|
|
|
|
|
|
|
|
/// Client indicates it is inactive.
|
2024-07-09 15:01:42 +00:00
|
|
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
2024-06-21 15:54:12 +00:00
|
|
|
#[xml(namespace = ns::CSI, name = "inactive")]
|
|
|
|
pub struct Inactive;
|
|
|
|
|
|
|
|
/// Client indicates it is active again.
|
2024-07-09 15:01:42 +00:00
|
|
|
#[derive(FromXml, AsXml, PartialEq, Debug, Clone)]
|
2024-06-21 15:54:12 +00:00
|
|
|
#[xml(namespace = ns::CSI, name = "active")]
|
|
|
|
pub struct Active;
|
2019-09-07 14:32:03 +00:00
|
|
|
|
|
|
|
#[cfg(test)]
|
|
|
|
mod tests {
|
|
|
|
use super::*;
|
2019-10-22 23:32:41 +00:00
|
|
|
use crate::ns;
|
2024-07-24 18:28:22 +00:00
|
|
|
use minidom::Element;
|
2019-09-07 14:32:03 +00:00
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn test_size() {
|
|
|
|
assert_size!(Feature, 0);
|
|
|
|
assert_size!(Inactive, 0);
|
|
|
|
assert_size!(Active, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn parsing() {
|
|
|
|
let elem: Element = "<csi xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
|
|
|
|
Feature::try_from(elem).unwrap();
|
|
|
|
|
|
|
|
let elem: Element = "<inactive xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
|
|
|
|
Inactive::try_from(elem).unwrap();
|
|
|
|
|
|
|
|
let elem: Element = "<active xmlns='urn:xmpp:csi:0'/>".parse().unwrap();
|
|
|
|
Active::try_from(elem).unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn serialising() {
|
|
|
|
let elem: Element = Feature.into();
|
|
|
|
assert!(elem.is("csi", ns::CSI));
|
|
|
|
|
|
|
|
let elem: Element = Inactive.into();
|
|
|
|
assert!(elem.is("inactive", ns::CSI));
|
|
|
|
|
|
|
|
let elem: Element = Active.into();
|
|
|
|
assert!(elem.is("active", ns::CSI));
|
|
|
|
}
|
|
|
|
}
|