mirror of
https://seed.radicle.dev/rad:z6cFWeWpnZNHh9rUW8phgA3b5yGt.git
synced 2026-10-25 14:20:31 +08:00
To help with clarity and potential publishing of the crates, the full `radicle-` prefix is used for the crate names. Note that it wasn't chosen got `git-ref-format` and `git-trailers` since they are truly general libraries (bar the feature flag for link specific reference names). Signed-off-by: Fintan Halpenny <fintan.halpenny@gmail.com>
77 lines
1.6 KiB
Rust
77 lines
1.6 KiB
Rust
// Copyright © 2019-2020 The Radicle Foundation <hello@radicle.foundation>
|
|
//
|
|
// This file is part of radicle-link, distributed under the GPLv3 with Radicle
|
|
// Linking Exception. For full terms see the included LICENSE file.
|
|
|
|
extern crate radicle_git_ext as git_ext;
|
|
extern crate radicle_std_ext as std_ext;
|
|
|
|
#[macro_use]
|
|
extern crate lazy_static;
|
|
#[macro_use]
|
|
extern crate radicle_macros;
|
|
|
|
pub mod namespace;
|
|
pub mod reference;
|
|
pub mod refspec;
|
|
pub mod remote;
|
|
pub mod urn;
|
|
pub use urn::Urn;
|
|
|
|
mod sealed;
|
|
|
|
pub use namespace::{AsNamespace, Namespace};
|
|
pub use reference::{
|
|
AsRemote,
|
|
Many,
|
|
Multiple,
|
|
One,
|
|
Reference as GenericRef,
|
|
RefsCategory,
|
|
Single,
|
|
SymbolicRef,
|
|
};
|
|
pub use refspec::{Fetchspec, Pushspec, Refspec};
|
|
|
|
/// Helper to aid type inference constructing a [`Reference`] without a
|
|
/// namespace.
|
|
pub struct Flat;
|
|
|
|
impl From<Flat> for Option<Namespace<git_ext::Oid>> {
|
|
fn from(_flat: Flat) -> Self {
|
|
None
|
|
}
|
|
}
|
|
|
|
/// Type specialised reference for the most common use within this crate.
|
|
pub type Reference<C, R> = GenericRef<Namespace<git_ext::Oid>, R, C>;
|
|
|
|
/// Whether we should force the overwriting of a reference or not.
|
|
#[derive(Debug, Clone, Copy)]
|
|
pub enum Force {
|
|
/// We should overwrite.
|
|
True,
|
|
/// We should not overwrite.
|
|
False,
|
|
}
|
|
|
|
impl Force {
|
|
/// Convert the Force to its `bool` equivalent.
|
|
fn as_bool(&self) -> bool {
|
|
match self {
|
|
Force::True => true,
|
|
Force::False => false,
|
|
}
|
|
}
|
|
}
|
|
|
|
impl From<bool> for Force {
|
|
fn from(b: bool) -> Self {
|
|
if b {
|
|
Self::True
|
|
} else {
|
|
Self::False
|
|
}
|
|
}
|
|
}
|