Skip to content

Commit 78d9bc0

Browse files
committed
first gentle test of adding serde support selectively.
Will miniserde work as well?
1 parent 4956ef2 commit 78d9bc0

File tree

4 files changed

+29
-1
lines changed

4 files changed

+29
-1
lines changed

Cargo.lock

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,8 @@ The top-level command-line interface.
175175

176176
### git-features
177177

178-
A crate to help controlling which capabilities are available from the top-level crate that uses `gitoxide`.
178+
A crate to help controlling which capabilities are available from the top-level crate that uses `gitoxide-core` or any other
179+
`gitoxide` crate that uses `git-features`.
179180
All feature toggles are additive.
180181

181182
* **parallel** _(optional)_
@@ -193,6 +194,18 @@ All feature toggles are additive.
193194
interface for progress.
194195
* This is by far the most expensive progress option, as it pulls in an `async` TUI along with supporting infrastructure,
195196
which is kept minimal but has quite a footprint nonetheless.
197+
198+
### Serialization Support
199+
200+
What follows is feature toggles to control serialization of all public facing simple data types.
201+
202+
* **with-serde**
203+
* Data structures implement `serde::Serialize` and `serde::Deserialize`
204+
205+
The features above are provided by the crates
206+
207+
* **git-object**
208+
196209

197210
## Development Practices
198211

git-object/Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,17 @@ edition = "2018"
88
[lib]
99
doctest = false
1010

11+
[features]
12+
with-serde = ["serde"]
13+
1114
[dependencies]
1215
quick-error = "1.2.3"
1316
hex = "0.4.2"
1417
btoi = "0.4.2"
1518
bstr = { version = "0.2.13", default-features = false, features = ["std"] }
1619
nom = { version = "6.0.0-alpha1", default-features = false, features = ["alloc"]}
1720
smallvec = "1.4.0"
21+
serde = { version = "1.0.114", optional = true, default-features = false, features = ["derive"]}
1822

1923
[dev-dependencies]
2024
pretty_assertions = "0.6.1"

git-object/src/types.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,18 @@ use nom::lib::std::fmt::Formatter;
33
use nom::lib::std::ops::Deref;
44
use quick_error::quick_error;
55

6+
#[cfg(feature = "with-serde")]
7+
use serde::{Deserialize, Serialize};
8+
69
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
10+
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
711
pub enum Sign {
812
Plus,
913
Minus,
1014
}
1115

1216
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
17+
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
1318
pub struct Time {
1419
/// time in seconds from epoch
1520
pub time: u32,
@@ -23,6 +28,7 @@ pub const SHA1_SIZE: usize = 20;
2328

2429
/// A SHA1 identifying objects
2530
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
31+
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
2632
pub struct Id(pub [u8; SHA1_SIZE]);
2733

2834
impl Id {
@@ -67,6 +73,7 @@ impl std::fmt::Display for Id {
6773
}
6874

6975
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone, Copy)]
76+
#[cfg_attr(feature = "with-serde", derive(Serialize, Deserialize))]
7077
pub enum Kind {
7178
Tree,
7279
Blob,

0 commit comments

Comments
 (0)