1 use std
::convert
::TryInto
;
3 use crate::{store, PartialNameRef, Reference}
;
6 use std
::convert
::Infallible
;
8 /// The error returned by [`crate::file::Store::find_loose()`].
9 #[derive(Debug, thiserror::Error)]
10 #[allow(missing_docs)]
12 #[error("An error occurred while finding a reference in the loose file database")]
13 Loose(#[from] crate::file::find::Error),
14 #[error("The ref name or path is not a valid ref name")]
15 RefnameValidation(#[from] crate::name::Error),
18 impl From
<Infallible
> for Error
{
19 fn from(_
: Infallible
) -> Self {
20 unreachable
!("this impl is needed to allow passing a known valid partial path as parameter")
27 use crate::store
::handle
;
30 /// TODO: actually implement this with handling of the packed buffer.
31 pub fn try_find
<'a
, Name
, E
>(&self, partial
: Name
) -> Result
<Option
<Reference
>, Error
>
33 Name
: TryInto
<&'a PartialNameRef
, Error
= E
>,
36 let _name
= partial
.try_into()?
;
38 handle
::State
::Loose { store: _, .. }
=> {
47 use std
::path
::PathBuf
;
49 /// The error returned by [file::Store::find_existing()][crate::file::Store::find_existing()].
50 #[derive(Debug, thiserror::Error)]
51 #[allow(missing_docs)]
53 #[error("An error occurred while finding a reference in the database")]
54 Find(#[from] crate::store::find::Error),
55 #[error("The ref partially named {name:?} could not be found")]
56 NotFound { name: PathBuf }
,
60 use std
::convert
::TryInto
;
64 use crate::{store, PartialNameRef, Reference}
;
67 /// Similar to [`crate::file::Store::find()`] but a non-existing ref is treated as error.
68 pub fn find
<'a
, Name
, E
>(&self, _partial
: Name
) -> Result
<Reference
, Error
>
70 Name
: TryInto
<&'a PartialNameRef
, Error
= E
>,
71 crate::name
::Error
: From
<E
>,
74 // match self.try_find(partial) {}
75 // match self.find_one_with_verified_input(path.to_partial_path().as_ref(), packed) {
76 // Ok(Some(r)) => Ok(r),
77 // Ok(None) => Err(Error::NotFound(path.to_partial_path().into_owned())),
78 // Err(err) => Err(err.into()),