parsers: Fix some issues reported by clippy.
This commit is contained in:
parent
ebf1091cf1
commit
464b5de0d0
10 changed files with 23 additions and 46 deletions
|
|
@ -16,7 +16,7 @@ generate_attribute!(
|
||||||
);
|
);
|
||||||
|
|
||||||
/// A conference bookmark.
|
/// A conference bookmark.
|
||||||
#[derive(Debug, Clone)]
|
#[derive(Debug, Clone, Default)]
|
||||||
pub struct Conference {
|
pub struct Conference {
|
||||||
/// Whether a conference bookmark should be joined automatically.
|
/// Whether a conference bookmark should be joined automatically.
|
||||||
pub autojoin: Autojoin,
|
pub autojoin: Autojoin,
|
||||||
|
|
@ -37,13 +37,7 @@ pub struct Conference {
|
||||||
impl Conference {
|
impl Conference {
|
||||||
/// Create a new conference.
|
/// Create a new conference.
|
||||||
pub fn new() -> Conference {
|
pub fn new() -> Conference {
|
||||||
Conference {
|
Conference::default()
|
||||||
autojoin: Autojoin::False,
|
|
||||||
name: None,
|
|
||||||
nick: None,
|
|
||||||
password: None,
|
|
||||||
extensions: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -46,9 +46,9 @@ impl IntoAttributeValue for DateTime {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Node> for DateTime {
|
impl From<DateTime> for Node {
|
||||||
fn into(self) -> Node {
|
fn from(date: DateTime) -> Node {
|
||||||
Node::Text(self.0.to_rfc3339())
|
Node::Text(date.0.to_rfc3339())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use std::net::IpAddr;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Wrapper element for an ICE-UDP transport.
|
/// Wrapper element for an ICE-UDP transport.
|
||||||
|
#[derive(Default)]
|
||||||
Transport, "transport", JINGLE_ICE_UDP,
|
Transport, "transport", JINGLE_ICE_UDP,
|
||||||
attributes: [
|
attributes: [
|
||||||
/// A Password as defined in ICE-CORE.
|
/// A Password as defined in ICE-CORE.
|
||||||
|
|
@ -29,12 +30,7 @@ generate_element!(
|
||||||
impl Transport {
|
impl Transport {
|
||||||
/// Create a new ICE-UDP transport.
|
/// Create a new ICE-UDP transport.
|
||||||
pub fn new() -> Transport {
|
pub fn new() -> Transport {
|
||||||
Transport {
|
Transport::default()
|
||||||
pwd: None,
|
|
||||||
ufrag: None,
|
|
||||||
candidates: Vec::new(),
|
|
||||||
fingerprint: None,
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a candidate to this transport.
|
/// Add a candidate to this transport.
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ use std::net::IpAddr;
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Wrapper element for an raw UDP transport.
|
/// Wrapper element for an raw UDP transport.
|
||||||
|
#[derive(Default)]
|
||||||
Transport, "transport", JINGLE_RAW_UDP,
|
Transport, "transport", JINGLE_RAW_UDP,
|
||||||
children: [
|
children: [
|
||||||
/// List of candidates for this raw UDP session.
|
/// List of candidates for this raw UDP session.
|
||||||
|
|
@ -19,9 +20,7 @@ generate_element!(
|
||||||
impl Transport {
|
impl Transport {
|
||||||
/// Create a new ICE-UDP transport.
|
/// Create a new ICE-UDP transport.
|
||||||
pub fn new() -> Transport {
|
pub fn new() -> Transport {
|
||||||
Transport {
|
Transport::default()
|
||||||
candidates: Vec::new(),
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Add a candidate to this transport.
|
/// Add a candidate to this transport.
|
||||||
|
|
|
||||||
|
|
@ -95,11 +95,7 @@ impl IqResultPayload for Join {}
|
||||||
impl Join {
|
impl Join {
|
||||||
/// Create a new Join element.
|
/// Create a new Join element.
|
||||||
pub fn from_nick_and_nodes<N: Into<String>>(nick: N, nodes: &[&str]) -> Join {
|
pub fn from_nick_and_nodes<N: Into<String>>(nick: N, nodes: &[&str]) -> Join {
|
||||||
let subscribes = nodes
|
let subscribes = nodes.iter().cloned().map(Subscribe::new).collect();
|
||||||
.into_iter()
|
|
||||||
.cloned()
|
|
||||||
.map(|n| Subscribe::new(n))
|
|
||||||
.collect();
|
|
||||||
Join {
|
Join {
|
||||||
id: None,
|
id: None,
|
||||||
nick: nick.into(),
|
nick: nick.into(),
|
||||||
|
|
@ -136,11 +132,7 @@ impl IqResultPayload for UpdateSubscription {}
|
||||||
impl UpdateSubscription {
|
impl UpdateSubscription {
|
||||||
/// Create a new UpdateSubscription element.
|
/// Create a new UpdateSubscription element.
|
||||||
pub fn from_nodes(nodes: &[&str]) -> UpdateSubscription {
|
pub fn from_nodes(nodes: &[&str]) -> UpdateSubscription {
|
||||||
let subscribes = nodes
|
let subscribes = nodes.iter().cloned().map(Subscribe::new).collect();
|
||||||
.into_iter()
|
|
||||||
.cloned()
|
|
||||||
.map(|n| Subscribe::new(n))
|
|
||||||
.collect();
|
|
||||||
UpdateSubscription {
|
UpdateSubscription {
|
||||||
jid: None,
|
jid: None,
|
||||||
subscribes,
|
subscribes,
|
||||||
|
|
@ -212,6 +204,7 @@ impl Mix {
|
||||||
|
|
||||||
generate_element!(
|
generate_element!(
|
||||||
/// Create a new MIX channel.
|
/// Create a new MIX channel.
|
||||||
|
#[derive(Default)]
|
||||||
Create, "create", MIX_CORE,
|
Create, "create", MIX_CORE,
|
||||||
attributes: [
|
attributes: [
|
||||||
/// The requested channel identifier.
|
/// The requested channel identifier.
|
||||||
|
|
@ -225,7 +218,7 @@ impl IqResultPayload for Create {}
|
||||||
impl Create {
|
impl Create {
|
||||||
/// Create a new ad-hoc Create element.
|
/// Create a new ad-hoc Create element.
|
||||||
pub fn new() -> Create {
|
pub fn new() -> Create {
|
||||||
Create { channel: None }
|
Create::default()
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Create a new Create element with a channel identifier.
|
/// Create a new Create element with a channel identifier.
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
use crate::ns;
|
use crate::ns;
|
||||||
use crate::util::error::Error;
|
use crate::util::error::Error;
|
||||||
use jid::Jid;
|
use jid::Jid;
|
||||||
use minidom::{Element, IntoAttributeValue, Node};
|
use minidom::{Element, IntoAttributeValue};
|
||||||
use std::collections::BTreeMap;
|
use std::collections::BTreeMap;
|
||||||
use std::convert::TryFrom;
|
use std::convert::TryFrom;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
|
|
@ -48,17 +48,16 @@ impl FromStr for Show {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Into<Node> for Show {
|
impl From<Show> for Element {
|
||||||
fn into(self) -> Node {
|
fn from(show: Show) -> Element {
|
||||||
Element::builder("show", ns::DEFAULT_NS)
|
Element::builder("show", ns::DEFAULT_NS)
|
||||||
.append(match self {
|
.append(match show {
|
||||||
Show::Away => "away",
|
Show::Away => "away",
|
||||||
Show::Chat => "chat",
|
Show::Chat => "chat",
|
||||||
Show::Dnd => "dnd",
|
Show::Dnd => "dnd",
|
||||||
Show::Xa => "xa",
|
Show::Xa => "xa",
|
||||||
})
|
})
|
||||||
.build()
|
.build()
|
||||||
.into()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ impl TryFrom<Element> for PubSubEvent {
|
||||||
return Err(Error::ParseError("Unknown child in event element."));
|
return Err(Error::ParseError("Unknown child in event element."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(payload.ok_or(Error::ParseError("No payload in event element."))?)
|
payload.ok_or(Error::ParseError("No payload in event element."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -164,7 +164,7 @@ impl TryFrom<Element> for PubSubOwner {
|
||||||
return Err(Error::ParseError("Unknown child in pubsub element."));
|
return Err(Error::ParseError("Unknown child in pubsub element."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(payload.ok_or(Error::ParseError("No payload in pubsub element."))?)
|
payload.ok_or(Error::ParseError("No payload in pubsub element."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -495,7 +495,7 @@ impl TryFrom<Element> for PubSub {
|
||||||
return Err(Error::ParseError("Unknown child in pubsub element."));
|
return Err(Error::ParseError("Unknown child in pubsub element."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(payload.ok_or(Error::ParseError("No payload in pubsub element."))?)
|
payload.ok_or(Error::ParseError("No payload in pubsub element."))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -71,11 +71,7 @@ impl TryFrom<Element> for XhtmlIm {
|
||||||
for child in elem.children() {
|
for child in elem.children() {
|
||||||
if child.is("body", ns::XHTML) {
|
if child.is("body", ns::XHTML) {
|
||||||
let child = child.clone();
|
let child = child.clone();
|
||||||
let lang = match child.attr("xml:lang") {
|
let lang = child.attr("xml:lang").unwrap_or("").to_string();
|
||||||
Some(lang) => lang,
|
|
||||||
None => "",
|
|
||||||
}
|
|
||||||
.to_string();
|
|
||||||
let body = Body::try_from(child)?;
|
let body = Body::try_from(child)?;
|
||||||
match bodies.insert(lang, body) {
|
match bodies.insert(lang, body) {
|
||||||
None => (),
|
None => (),
|
||||||
|
|
@ -488,9 +484,9 @@ fn parse_css(style: Option<&str>) -> Css {
|
||||||
let mut properties = vec![];
|
let mut properties = vec![];
|
||||||
if let Some(style) = style {
|
if let Some(style) = style {
|
||||||
// TODO: make that parser a bit more resilient to things.
|
// TODO: make that parser a bit more resilient to things.
|
||||||
for part in style.split(";") {
|
for part in style.split(';') {
|
||||||
let mut part = part
|
let mut part = part
|
||||||
.splitn(2, ":")
|
.splitn(2, ':')
|
||||||
.map(|a| a.to_string())
|
.map(|a| a.to_string())
|
||||||
.collect::<Vec<_>>();
|
.collect::<Vec<_>>();
|
||||||
let key = part.pop().unwrap();
|
let key = part.pop().unwrap();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue