Unified · Split
| @@ -1,6 +1,7 @@ | |||
| 1 | use std::ops::Range; | 1 | use std::ops::Range; |
| 2 | 2 | ||
| 3 | use bstr::{BStr, BString, ByteSlice}; | 3 | use bstr::{BStr, BString, ByteSlice}; |
| 4 | use winnow::prelude::*; | ||
| 4 | 5 | ||
| 5 | use crate::{Commit, CommitRef, TagRef}; | 6 | use crate::{Commit, CommitRef, TagRef}; |
| 6 | 7 | ||
| @@ -60,7 +61,9 @@ mod write; · 53 unmodified lines | |||
| 60 | impl<'a> CommitRef<'a> { | 61 | impl<'a> CommitRef<'a> { |
| 61 | /// Deserialize a commit from the given `data` bytes while avoiding most allocations. | 62 | /// Deserialize a commit from the given `data` bytes while avoiding most allocations. |
| 62 | pub fn from_bytes(mut data: &'a [u8]) -> Result<CommitRef<'a>, crate::decode::Error> { | 63 | pub fn from_bytes(mut data: &'a [u8]) -> Result<CommitRef<'a>, crate::decode::Error> { |
| 63 | decode::commit(&mut data).map_err(crate::decode::Error::with_err) | 64 | decode::commit |
| 65 | .parse_next(&mut data) | ||
| 66 | .map_err(crate::decode::Error::with_err) | ||
| 64 | } | 67 | } |
| 65 | } | 68 | } |
| 66 | 69 | ||
| @@ -1,3 +1,5 @@ | |||
| 1 | use winnow::prelude::*; | ||
| 2 | |||
| 1 | use crate::TagRef; | 3 | use crate::TagRef; |
| 2 | 4 | ||
| 3 | mod decode; | 5 | mod decode; |
| @@ -11,7 +13,9 @@ pub mod ref_iter; · 7 unmodified lines | |||
| 11 | impl<'a> TagRef<'a> { | 13 | impl<'a> TagRef<'a> { |
| 12 | /// Deserialize a tag from `data`. | 14 | /// Deserialize a tag from `data`. |
| 13 | pub fn from_bytes(mut data: &'a [u8]) -> Result<TagRef<'a>, crate::decode::Error> { | 15 | pub fn from_bytes(mut data: &'a [u8]) -> Result<TagRef<'a>, crate::decode::Error> { |
| 14 | decode::git_tag(&mut data).map_err(crate::decode::Error::with_err) | 16 | decode::git_tag |
| 17 | .parse_next(&mut data) | ||
| 18 | .map_err(crate::decode::Error::with_err) | ||
| 15 | } | 19 | } |
| 16 | /// The object this tag points to as `Id`. | 20 | /// The object this tag points to as `Id`. |
| 17 | pub fn target(&self) -> gix_hash::ObjectId { | 21 | pub fn target(&self) -> gix_hash::ObjectId { |
| @@ -2,6 +2,7 @@ use std::convert::TryFrom; · 1 unmodified line | |||
| 2 | 2 | ||
| 3 | use bstr::BStr; | 3 | use bstr::BStr; |
| 4 | use winnow::error::ParserError; | 4 | use winnow::error::ParserError; |
| 5 | use winnow::prelude::*; | ||
| 5 | 6 | ||
| 6 | use crate::{tree, tree::EntryRef, TreeRef, TreeRefIter}; | 7 | use crate::{tree, tree::EntryRef, TreeRef, TreeRefIter}; |
| 7 | 8 | ||
| @@ -15,7 +16,9 @@ impl<'a> TreeRefIter<'a> { · 7 unmodified lines | |||
| 15 | impl<'a> TreeRef<'a> { | 16 | impl<'a> TreeRef<'a> { |
| 16 | /// Deserialize a Tree from `data`. | 17 | /// Deserialize a Tree from `data`. |
| 17 | pub fn from_bytes(mut data: &'a [u8]) -> Result<TreeRef<'a>, crate::decode::Error> { | 18 | pub fn from_bytes(mut data: &'a [u8]) -> Result<TreeRef<'a>, crate::decode::Error> { |
| 18 | decode::tree(&mut data).map_err(crate::decode::Error::with_err) | 19 | decode::tree |
| 20 | .parse_next(&mut data) | ||
| 21 | .map_err(crate::decode::Error::with_err) | ||
| 19 | } | 22 | } |
| 20 | 23 | ||
| 21 | /// Find an entry named `name` knowing if the entry is a directory or not, using a binary search. | 24 | /// Find an entry named `name` knowing if the entry is a directory or not, using a binary search. |