summaryrefslogtreecommitdiffstats
path: root/vendor/gix-attributes/src/name.rs
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/gix-attributes/src/name.rs')
-rw-r--r--vendor/gix-attributes/src/name.rs47
1 files changed, 47 insertions, 0 deletions
diff --git a/vendor/gix-attributes/src/name.rs b/vendor/gix-attributes/src/name.rs
new file mode 100644
index 000000000..03064dbda
--- /dev/null
+++ b/vendor/gix-attributes/src/name.rs
@@ -0,0 +1,47 @@
+use bstr::BString;
+
+use crate::{Name, NameRef};
+
+impl<'a> NameRef<'a> {
+ /// Turn this ref into its owned counterpart.
+ pub fn to_owned(self) -> Name {
+ Name(self.0.into())
+ }
+
+ /// Return the inner `str`.
+ pub fn as_str(&self) -> &str {
+ self.0
+ }
+}
+
+impl AsRef<str> for NameRef<'_> {
+ fn as_ref(&self) -> &str {
+ self.0
+ }
+}
+
+impl<'a> Name {
+ /// Provide our ref-type.
+ pub fn as_ref(&'a self) -> NameRef<'a> {
+ NameRef(self.0.as_ref())
+ }
+
+ /// Return the inner `str`.
+ pub fn as_str(&self) -> &str {
+ self.0.as_str()
+ }
+}
+
+impl AsRef<str> for Name {
+ fn as_ref(&self) -> &str {
+ self.0.as_str()
+ }
+}
+
+/// The error returned by [`parse::Iter`][crate::parse::Iter].
+#[derive(Debug, thiserror::Error)]
+#[error("Attribute has non-ascii characters or starts with '-': {attribute}")]
+pub struct Error {
+ /// The attribute that failed to parse.
+ pub attribute: BString,
+}