ali_oss/types/
bucket_location.rs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#[derive(Debug, Clone)]
pub struct BucketLocation(String);

impl AsRef<str> for BucketLocation {
	fn as_ref(&self) -> &str {
		&self.0
	}
}

impl BucketLocation {
	pub fn new<T: ToString>(location: T) -> Self {
		Self(location.to_string())
	}
	pub fn new_from_xml_node(node: roxmltree::Node) -> anyhow::Result<Self> {
		let location = node.descendants().find(|n| n.has_tag_name("LocationConstraint")).and_then(|node| node.text()).unwrap_or("");
		Ok(Self(location.to_string()))
	}
	pub fn as_str(&self) -> &str {
		&self.0
	}
}