Skip to content

Commit

Permalink
Box errors with Send and Sync
Browse files Browse the repository at this point in the history
  • Loading branch information
jameswald authored and dginev committed Jan 19, 2022
1 parent 40020e1 commit 2c669a9
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
2 changes: 1 addition & 1 deletion src/tree/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ pub struct Namespace {

impl Namespace {
/// Creates a new namespace
pub fn new(prefix: &str, href: &str, node: &mut Node) -> Result<Self, Box<dyn Error>> {
pub fn new(prefix: &str, href: &str, node: &mut Node) -> Result<Self, Box<dyn Error + Send + Sync>> {
let c_href = CString::new(href).unwrap();
let c_prefix = CString::new(prefix).unwrap();
let c_prefix_ptr = if prefix.is_empty() {
Expand Down
36 changes: 18 additions & 18 deletions src/tree/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -335,7 +335,7 @@ impl Node {
}

/// Add a previous sibling
pub fn add_prev_sibling(&mut self, new_sibling: &mut Node) -> Result<(), Box<dyn Error>> {
pub fn add_prev_sibling(&mut self, new_sibling: &mut Node) -> Result<(), Box<dyn Error + Send + Sync>> {
new_sibling.set_linked();
unsafe {
if xmlAddPrevSibling(self.node_ptr_mut()?, new_sibling.node_ptr_mut()?).is_null() {
Expand All @@ -347,7 +347,7 @@ impl Node {
}

/// Add a next sibling
pub fn add_next_sibling(&mut self, new_sibling: &mut Node) -> Result<(), Box<dyn Error>> {
pub fn add_next_sibling(&mut self, new_sibling: &mut Node) -> Result<(), Box<dyn Error + Send + Sync>> {
new_sibling.set_linked();
unsafe {
if xmlAddNextSibling(self.node_ptr_mut()?, new_sibling.node_ptr_mut()?).is_null() {
Expand Down Expand Up @@ -384,7 +384,7 @@ impl Node {
}

/// Sets the name of this `Node`
pub fn set_name(&mut self, name: &str) -> Result<(), Box<dyn Error>> {
pub fn set_name(&mut self, name: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
let c_name = CString::new(name).unwrap();
unsafe { xmlNodeSetName(self.node_ptr_mut()?, c_name.as_bytes().as_ptr()) }
Ok(())
Expand All @@ -407,7 +407,7 @@ impl Node {
}

/// Sets the text content of this `Node`
pub fn set_content(&mut self, content: &str) -> Result<(), Box<dyn Error>> {
pub fn set_content(&mut self, content: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
let c_content = CString::new(content).unwrap();
unsafe { xmlNodeSetContent(self.node_ptr_mut()?, c_content.as_bytes().as_ptr()) }
Ok(())
Expand Down Expand Up @@ -461,7 +461,7 @@ impl Node {
}

/// Sets the value of property `name` to `value`
pub fn set_property(&mut self, name: &str, value: &str) -> Result<(), Box<dyn Error>> {
pub fn set_property(&mut self, name: &str, value: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
let c_name = CString::new(name).unwrap();
let c_value = CString::new(value).unwrap();
unsafe {
Expand All @@ -479,7 +479,7 @@ impl Node {
name: &str,
value: &str,
ns: &Namespace,
) -> Result<(), Box<dyn Error>> {
) -> Result<(), Box<dyn Error + Send + Sync>> {
let c_name = CString::new(name).unwrap();
let c_value = CString::new(value).unwrap();
unsafe {
Expand All @@ -494,7 +494,7 @@ impl Node {
}

/// Removes the property of given `name`
pub fn remove_property(&mut self, name: &str) -> Result<(), Box<dyn Error>> {
pub fn remove_property(&mut self, name: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
let c_name = CString::new(name).unwrap();
unsafe {
let attr_node = xmlHasProp(self.node_ptr_mut()?, c_name.as_bytes().as_ptr());
Expand All @@ -517,7 +517,7 @@ impl Node {
}

/// Removes the property of given `name` and namespace (`ns`)
pub fn remove_property_ns(&mut self, name: &str, ns: &str) -> Result<(), Box<dyn Error>> {
pub fn remove_property_ns(&mut self, name: &str, ns: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
let c_name = CString::new(name).unwrap();
let c_ns = CString::new(ns).unwrap();
unsafe {
Expand Down Expand Up @@ -559,7 +559,7 @@ impl Node {
}

/// Alias for set_property
pub fn set_attribute(&mut self, name: &str, value: &str) -> Result<(), Box<dyn Error>> {
pub fn set_attribute(&mut self, name: &str, value: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
self.set_property(name, value)
}
/// Alias for set_property_ns
Expand All @@ -568,17 +568,17 @@ impl Node {
name: &str,
value: &str,
ns: &Namespace,
) -> Result<(), Box<dyn Error>> {
) -> Result<(), Box<dyn Error + Send + Sync>> {
self.set_property_ns(name, value, ns)
}

/// Alias for remove_property
pub fn remove_attribute(&mut self, name: &str) -> Result<(), Box<dyn Error>> {
pub fn remove_attribute(&mut self, name: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
self.remove_property(name)
}

/// Alias for remove_property_ns
pub fn remove_attribute_ns(&mut self, name: &str, ns: &str) -> Result<(), Box<dyn Error>> {
pub fn remove_attribute_ns(&mut self, name: &str, ns: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
self.remove_property_ns(name, ns)
}

Expand Down Expand Up @@ -668,7 +668,7 @@ impl Node {
}

/// Sets a `Namespace` for the node
pub fn set_namespace(&mut self, namespace: &Namespace) -> Result<(), Box<dyn Error>> {
pub fn set_namespace(&mut self, namespace: &Namespace) -> Result<(), Box<dyn Error + Send + Sync>> {
unsafe {
xmlSetNs(self.node_ptr_mut()?, namespace.ns_ptr());
}
Expand Down Expand Up @@ -722,7 +722,7 @@ impl Node {

// TODO: Clear a future Document namespaces vec
/// Removes the namespaces of this `Node` and it's children!
pub fn recursively_remove_namespaces(&mut self) -> Result<(), Box<dyn Error>> {
pub fn recursively_remove_namespaces(&mut self) -> Result<(), Box<dyn Error + Send + Sync>> {
xmlNodeRecursivelyRemoveNs(self.node_ptr_mut()?);
Ok(())
}
Expand Down Expand Up @@ -752,7 +752,7 @@ impl Node {
}

/// Creates a new `Node` as child to the self `Node`
pub fn new_child(&mut self, ns: Option<Namespace>, name: &str) -> Result<Node, Box<dyn Error>> {
pub fn new_child(&mut self, ns: Option<Namespace>, name: &str) -> Result<Node, Box<dyn Error + Send + Sync>> {
let c_name = CString::new(name).unwrap();
let ns_ptr = match ns {
None => ptr::null_mut(),
Expand All @@ -775,7 +775,7 @@ impl Node {
ns: Option<Namespace>,
name: &str,
content: &str,
) -> Result<Node, Box<dyn Error>> {
) -> Result<Node, Box<dyn Error + Send + Sync>> {
let c_name = CString::new(name).unwrap();
let c_content = CString::new(content).unwrap();
let ns_ptr = match ns {
Expand All @@ -794,7 +794,7 @@ impl Node {
}

/// Append text to this `Node`
pub fn append_text(&mut self, content: &str) -> Result<(), Box<dyn Error>> {
pub fn append_text(&mut self, content: &str) -> Result<(), Box<dyn Error + Send + Sync>> {
let c_len = content.len() as i32;
if c_len > 0 {
let c_content = CString::new(content).unwrap();
Expand Down Expand Up @@ -878,7 +878,7 @@ impl Node {
&mut self,
mut new: Node,
mut old: Node,
) -> Result<Node, Box<dyn Error>> {
) -> Result<Node, Box<dyn Error + Send + Sync>> {
// if newNode == oldNode or self == newNode then do nothing, just return nNode.
if new == old || self == &new {
// nothing to do here, already in place
Expand Down

0 comments on commit 2c669a9

Please sign in to comment.