Skip to content

Commit

Permalink
fix: add serde support for varous reference name types.
Browse files Browse the repository at this point in the history
  • Loading branch information
Byron committed Aug 8, 2024
1 parent 8a27454 commit 70d835b
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions gix-ref/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,12 @@ pub(crate) struct Store {
inner: store::State,
}

/// A validated complete and fully qualified referenced reference name, safe to use for all operations.
/// A validated complete and fully qualified reference name, safe to use for all operations.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct FullName(pub(crate) BString);

/// A validated complete and fully qualified referenced reference name, safe to use for all operations.
/// A validated complete and fully qualified reference name, safe to use for all operations.
#[derive(Hash, Debug, PartialEq, Eq, Ord, PartialOrd)]
#[repr(transparent)]
pub struct FullNameRef(BStr);
Expand All @@ -138,10 +138,12 @@ pub struct PartialNameRef(BStr);

/// A validated and potentially partial reference name, safe to use for common operations.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct PartialName(BString);

/// A _validated_ prefix for references to act as a namespace.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct Namespace(BString);

/// Denotes the kind of reference.
Expand All @@ -160,6 +162,7 @@ pub enum Kind {
///
/// This translates into a prefix containing all references of a given category.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub enum Category<'a> {
/// A tag in `refs/tags`
Tag,
Expand All @@ -179,6 +182,7 @@ pub enum Category<'a> {
/// A `PseudoRef` in another _linked_ worktree, never in the main one, like `worktrees/<id>/HEAD`.
LinkedPseudoRef {
/// The name of the worktree.
#[cfg_attr(feature = "serde", serde(borrow))]
name: &'a BStr,
},
/// Any reference that is prefixed with `worktrees/<id>/refs/`.
Expand Down

0 comments on commit 70d835b

Please sign in to comment.