gix_actor/
lib.rs

1//! This crate provides ways of identifying an actor within the git repository both in shared and mutable variants.
2//!
3//! ## Feature Flags
4#![cfg_attr(
5    all(doc, feature = "document-features"),
6    doc = ::document_features::document_features!()
7)]
8#![cfg_attr(all(doc, feature = "document-features"), feature(doc_cfg, doc_auto_cfg))]
9#![deny(missing_docs, rust_2018_idioms)]
10#![forbid(unsafe_code)]
11
12/// The re-exported `bstr` crate.
13///
14/// For convenience to allow using `bstr` without adding it to own cargo manifest.
15pub use bstr;
16use bstr::{BStr, BString};
17/// The re-exported `gix-date` crate.
18///
19/// For convenience to allow using `gix-date` without adding it to own cargo manifest.
20pub use gix_date as date;
21use gix_date::Time;
22
23mod identity;
24///
25pub mod signature;
26
27/// A person with name and email.
28#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
29#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
30pub struct Identity {
31    /// The actors name.
32    pub name: BString,
33    /// The actor's email.
34    pub email: BString,
35}
36
37/// A person with name and email, as reference.
38#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
39#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
40pub struct IdentityRef<'a> {
41    /// The actors name.
42    #[cfg_attr(feature = "serde", serde(borrow))]
43    pub name: &'a BStr,
44    /// The actor's email.
45    pub email: &'a BStr,
46}
47
48/// A mutable signature is created by an actor at a certain time.
49///
50/// Note that this is not a cryptographical signature.
51#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
52#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
53pub struct Signature {
54    /// The actors name.
55    pub name: BString,
56    /// The actor's email.
57    pub email: BString,
58    /// The time stamp at which the signature is performed.
59    pub time: Time,
60}
61
62/// A immutable signature is created by an actor at a certain time.
63///
64/// Note that this is not a cryptographical signature.
65#[derive(Default, PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
66#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
67pub struct SignatureRef<'a> {
68    /// The actor's name.
69    #[cfg_attr(feature = "serde", serde(borrow))]
70    pub name: &'a BStr,
71    /// The actor's email.
72    pub email: &'a BStr,
73    /// The time stamp at which the signature was performed.
74    pub time: gix_date::Time,
75}