Skip to content

Commit 76e66d1

Browse files
committed
[pack #179] refactor
1 parent 34e45d7 commit 76e66d1

File tree

4 files changed

+28
-27
lines changed

4 files changed

+28
-27
lines changed

git-pack/CHANGELOG.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
- `bundle::Bundle` -> `Bundle`
1111
- `bundle::Error` -> `bundle::init::Error`
1212
- `pub tree::` -> `pub(crate) cache::delta::`
13-
13+
- `data::object::Object` -> `data::Object`
14+
- `data::entry::Entry` -> `data::Entry`
15+
1416
* **new methods**
1517
- `Find::find_tag_iter()`

git-pack/src/data/entry/mod.rs

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
use crate::data::Entry;
12
use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
23

34
const _TYPE_EXT1: u8 = 0;
@@ -9,18 +10,6 @@ const _TYPE_EXT2: u8 = 5;
910
const OFS_DELTA: u8 = 6;
1011
const REF_DELTA: u8 = 7;
1112

12-
/// An representing an full- or delta-object within a pack
13-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
14-
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
15-
pub struct Entry {
16-
/// The entry's header
17-
pub header: Header,
18-
/// The decompressed size of the object in bytes
19-
pub decompressed_size: u64,
20-
/// absolute offset to compressed object data in the pack, just behind the entry's header
21-
pub data_offset: u64,
22-
}
23-
2413
/// Access
2514
impl Entry {
2615
/// Compute the pack offset to the base entry of the object represented by this entry.

git-pack/src/data/mod.rs

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,38 @@ use std::{convert::TryInto, path::Path};
44
use filebuffer::FileBuffer;
55
use git_hash::SIZE_OF_SHA1_DIGEST as SHA1_SIZE;
66

7+
/// An representing an full- or delta-object within a pack
8+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
9+
#[cfg_attr(feature = "serde1", derive(serde::Serialize, serde::Deserialize))]
10+
pub struct Entry {
11+
/// The entry's header
12+
pub header: entry::Header,
13+
/// The decompressed size of the object in bytes
14+
pub decompressed_size: u64,
15+
/// absolute offset to compressed object data in the pack, just behind the entry's header
16+
pub data_offset: u64,
17+
}
18+
19+
/// A borrowed object using a borrowed slice as backing buffer.
20+
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
21+
pub struct Object<'a> {
22+
/// kind of object
23+
pub kind: git_object::Kind,
24+
/// decoded, decompressed data, owned by a backing store.
25+
pub data: &'a [u8],
26+
/// If `Some`, this object is from a pack whose pack location can be used to look up pack related information
27+
pub pack_location: Option<crate::bundle::Location>,
28+
}
29+
730
mod file;
831
pub use file::{decode_entry, verify, ResolvedBase};
932
///
1033
pub mod header;
1134

1235
///
1336
pub mod entry;
14-
#[doc(inline)]
15-
pub use entry::Entry;
1637

1738
pub mod object;
18-
pub use object::Object;
1939

2040
///
2141
pub mod input;

git-pack/src/data/object.rs

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,8 @@
11
//! Contains a borrowed Object bound to a buffer holding its decompressed data.
22
3+
use crate::data::Object;
34
use git_object::{BlobRef, CommitRef, CommitRefIter, ObjectRef, TagRef, TagRefIter, TreeRef, TreeRefIter};
45

5-
/// A borrowed object using a borrowed slice as backing buffer.
6-
#[derive(PartialEq, Eq, Debug, Hash, Ord, PartialOrd, Clone)]
7-
pub struct Object<'a> {
8-
/// kind of object
9-
pub kind: git_object::Kind,
10-
/// decoded, decompressed data, owned by a backing store.
11-
pub data: &'a [u8],
12-
/// If `Some`, this object is from a pack whose pack location can be used to look up pack related information
13-
pub pack_location: Option<crate::bundle::Location>,
14-
}
15-
166
impl<'a> Object<'a> {
177
/// Constructs a new data object from `kind` and `data`.
188
pub fn new(kind: git_object::Kind, data: &'a [u8]) -> Object<'a> {

0 commit comments

Comments
 (0)