aboutsummaryrefslogtreecommitdiffstats
path: root/src/document_tree
diff options
context:
space:
mode:
authorPhilipp A2018-12-02 12:37:31 +0100
committerPhilipp A2018-12-02 12:37:31 +0100
commitfad2dff1c719470a4ed8542b05a210056de6949a (patch)
tree69142a504f085e6350e071a4c2d35a7b0e7e3b73 /src/document_tree
parent30f5d8b4a22c189bc8a4b24e9cf2bb4907ef191b (diff)
downloadrust-rst-fad2dff1c719470a4ed8542b05a210056de6949a.tar.bz2
Switched url to target
Diffstat (limited to 'src/document_tree')
-rw-r--r--src/document_tree/elements.rs16
-rw-r--r--src/document_tree/extra_attributes.rs21
-rw-r--r--src/document_tree/serde_util.rs12
3 files changed, 14 insertions, 35 deletions
diff --git a/src/document_tree/elements.rs b/src/document_tree/elements.rs
index 2b99d97..5f669ae 100644
--- a/src/document_tree/elements.rs
+++ b/src/document_tree/elements.rs
@@ -1,7 +1,6 @@
use serde_derive::Serialize;
-use url::Url;
-use super::serde_util::serialize_opt_url;
+use crate::target;
use super::extra_attributes::{self,ExtraAttributes};
use super::element_categories::*;
@@ -15,8 +14,8 @@ pub trait Element {
fn ids_mut(&mut self) -> &mut Vec<String>;
fn names (& self) -> & Vec<String>;
fn names_mut(&mut self) -> &mut Vec<String>;
- fn source (& self) -> & Option<Url>;
- fn source_mut(&mut self) -> &mut Option<Url>;
+ fn source (& self) -> & Option<target::Target>;
+ fn source_mut(&mut self) -> &mut Option<target::Target>;
fn classes (& self) -> & Vec<String>;
fn classes_mut(&mut self) -> &mut Vec<String>;
}
@@ -25,8 +24,7 @@ pub trait Element {
pub struct CommonAttributes {
ids: Vec<String>,
names: Vec<String>,
- #[serde(serialize_with = "serialize_opt_url")]
- source: Option<Url>,
+ source: Option<target::Target>,
classes: Vec<String>,
//left out dupnames
}
@@ -41,8 +39,8 @@ macro_rules! impl_element { ($name:ident) => (
fn ids_mut(&mut self) -> &mut Vec<String> { &mut self.common.ids }
fn names (& self) -> & Vec<String> { & self.common.names }
fn names_mut(&mut self) -> &mut Vec<String> { &mut self.common.names }
- fn source (& self) -> & Option<Url> { & self.common.source }
- fn source_mut(&mut self) -> &mut Option<Url> { &mut self.common.source }
+ fn source (& self) -> & Option<target::Target> { & self.common.source }
+ fn source_mut(&mut self) -> &mut Option<target::Target> { &mut self.common.source }
fn classes (& self) -> & Vec<String> { & self.common.classes }
fn classes_mut(&mut self) -> &mut Vec<String> { &mut self.common.classes }
}
@@ -251,7 +249,7 @@ impl_elems!(
);
impl<'a> From<&'a str> for TextOrInlineElement {
- fn from(s: &'a str) -> TextOrInlineElement {
+ fn from(s: &'a str) -> Self {
s.to_owned().into()
}
}
diff --git a/src/document_tree/extra_attributes.rs b/src/document_tree/extra_attributes.rs
index 2019dec..c926113 100644
--- a/src/document_tree/extra_attributes.rs
+++ b/src/document_tree/extra_attributes.rs
@@ -1,8 +1,6 @@
-use url::Url;
-
use serde_derive::Serialize;
-use super::serde_util::{serialize_url,serialize_opt_url};
+use crate::target;
use super::attribute_types::{FixedSpace,ID,NameToken,AlignHV,AlignH,Measure,EnumeratedListType};
pub trait ExtraAttributes<A> {
@@ -32,23 +30,20 @@ impl_extra!(DoctestBlock { space: FixedSpace });
impl_extra!(SubstitutionDefinition { ltrim: Option<bool>, rtrim: Option<bool> });
impl_extra!(Comment { space: FixedSpace });
impl_extra!(Target {
- #[serde(serialize_with = "serialize_opt_url")]
- refuri: Option<Url>,
+ refuri: Option<target::Target>,
refid: Option<ID>,
refname: Vec<NameToken>,
anonymous: bool,
});
impl_extra!(Raw { space: FixedSpace, format: Vec<NameToken> });
impl_extra!(#[derive(Debug,Serialize)] Image {
- #[serde(serialize_with = "serialize_url")]
- uri: Url,
+ uri: target::Target,
align: Option<AlignHV>,
alt: Option<String>,
height: Option<Measure>,
width: Option<Measure>,
scale: Option<u8>,
- #[serde(serialize_with = "serialize_opt_url")]
- target: Option<Url>, // Not part of the DTD but a valid argument
+ target: Option<target::Target>, // Not part of the DTD but a valid argument
});
//bools usually are XML yesorno. “auto” however either exists and is set to something random like “1” or doesn’t exist
@@ -66,8 +61,7 @@ impl_extra!(OptionArgument { delimiter: Option<String> });
impl_extra!(Reference {
name: Option<String>,
- #[serde(serialize_with = "serialize_opt_url")]
- refuri: Option<Url>,
+ refuri: Option<target::Target>,
refid: Option<ID>,
refname: Vec<NameToken>,
});
@@ -78,8 +72,7 @@ impl_extra!(Problematic { refid: Option<ID> });
//also have non-inline versions. Inline image is no figure child, inline target has content
impl_extra!(TargetInline {
- #[serde(serialize_with = "serialize_opt_url")]
- refuri: Option<Url>,
+ refuri: Option<target::Target>,
refid: Option<ID>,
refname: Vec<NameToken>,
anonymous: bool,
@@ -88,7 +81,7 @@ impl_extra!(RawInline { space: FixedSpace, format: Vec<NameToken> });
pub type ImageInline = Image;
impl Image {
- pub fn new(uri: Url) -> Image { Image {
+ pub fn new(uri: target::Target) -> Image { Image {
uri: uri,
align: None,
alt: None,
diff --git a/src/document_tree/serde_util.rs b/src/document_tree/serde_util.rs
deleted file mode 100644
index 2e24309..0000000
--- a/src/document_tree/serde_util.rs
+++ /dev/null
@@ -1,12 +0,0 @@
-use url::Url;
-
-pub fn serialize_url<S>(url: &Url, serializer: S) -> Result<S::Ok, S::Error> where S: serde::ser::Serializer {
- serializer.serialize_str(url.as_str())
-}
-
-pub fn serialize_opt_url<S>(url_opt: &Option<Url>, serializer: S) -> Result<S::Ok, S::Error> where S: serde::ser::Serializer {
- match url_opt {
- Some(ref url) => serializer.serialize_some(url.as_str()),
- None => serializer.serialize_none(),
- }
-}