Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 0 additions & 31 deletions git-actor/src/immutable/mod.rs

This file was deleted.

157 changes: 0 additions & 157 deletions git-actor/src/immutable/signature.rs

This file was deleted.

27 changes: 22 additions & 5 deletions git-actor/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
//! This crate provides ways of identifying an actor within the git repository both in shared/immutable and mutable variants.
//! This crate provides ways of identifying an actor within the git repository both in shared/signature_ref and mutable variants.
#![forbid(unsafe_code)]
#![deny(rust_2018_idioms, missing_docs)]
use bstr::BString;
use bstr::{BStr, BString};

pub mod immutable;
mod signature;
///
pub mod signature;
///
pub mod signature_ref;

const SPACE: &[u8; 1] = b" ";

Expand All @@ -22,6 +24,21 @@ pub struct Signature {
pub time: Time,
}

/// A immutable signature is created by an actor at a certain time.
///
/// Note that this is not a cryptographical signature.
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
pub struct SignatureRef<'a> {
/// The actor's name.
#[cfg_attr(feature = "serde1", serde(borrow))]
pub name: &'a BStr,
/// The actor's email.
pub email: &'a BStr,
/// The time stamp at which the signature was performed.
pub time: Time,
}

/// Indicates if a number is positive or negative for use in [`Time`].
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
Expand All @@ -43,4 +60,4 @@ pub struct Time {
pub sign: Sign,
}

mod types;
mod time;
29 changes: 22 additions & 7 deletions git-actor/src/signature.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,24 @@
mod convert {
use crate::{immutable, Signature};
use crate::{Sign, Signature, SignatureRef, Time};

impl From<immutable::Signature<'_>> for Signature {
fn from(other: immutable::Signature<'_>) -> Signature {
let immutable::Signature { name, email, time } = other;
impl Signature {
/// An empty signature, similar to 'null'.
pub fn empty() -> Self {
Signature {
name: Default::default(),
email: Default::default(),
time: Time {
time: 0,
offset: 0,
sign: Sign::Plus,
},
}
}
}

impl From<SignatureRef<'_>> for Signature {
fn from(other: SignatureRef<'_>) -> Signature {
let SignatureRef { name, email, time } = other;
Signature {
name: name.to_owned(),
email: email.to_owned(),
Expand All @@ -13,9 +28,9 @@ mod convert {
}

impl Signature {
/// Borrow this instance as immutable
pub fn borrow(&self) -> immutable::Signature<'_> {
immutable::Signature {
/// Borrow this instance as signature_ref
pub fn to_ref(&self) -> SignatureRef<'_> {
SignatureRef {
name: self.name.as_ref(),
email: self.email.as_ref(),
time: self.time,
Expand Down
Loading