gix_ref/store/general/handle/
find.rs1use crate::{store, PartialNameRef, Reference};
2
3mod error {
4    use std::convert::Infallible;
5
6    #[derive(Debug, thiserror::Error)]
8    #[allow(missing_docs)]
9    pub enum Error {
10        #[error("An error occurred while finding a reference in the loose file database")]
11        Loose(#[from] crate::file::find::Error),
12        #[error("The ref name or path is not a valid ref name")]
13        RefnameValidation(#[from] crate::name::Error),
14    }
15
16    impl From<Infallible> for Error {
17        fn from(_: Infallible) -> Self {
18            unreachable!("this impl is needed to allow passing a known valid partial path as parameter")
19        }
20    }
21}
22
23pub use error::Error;
24
25use crate::store::handle;
26
27impl store::Handle {
28    pub fn try_find<'a, Name, E>(&self, partial: Name) -> Result<Option<Reference>, Error>
30    where
31        Name: TryInto<&'a PartialNameRef, Error = E>,
32        Error: From<E>,
33    {
34        let _name = partial.try_into()?;
35        match &self.state {
36            handle::State::Loose { store: _, .. } => {
37                todo!()
38            }
39        }
40    }
41}
42
43mod existing {
44    mod error {
45        use std::path::PathBuf;
46
47        #[derive(Debug, thiserror::Error)]
49        #[allow(missing_docs)]
50        pub enum Error {
51            #[error("An error occurred while finding a reference in the database")]
52            Find(#[from] crate::store::find::Error),
53            #[error("The ref partially named {name:?} could not be found")]
54            NotFound { name: PathBuf },
55        }
56    }
57
58    pub use error::Error;
59
60    use crate::{store, PartialNameRef, Reference};
61
62    impl store::Handle {
63        pub fn find<'a, Name, E>(&self, _partial: Name) -> Result<Reference, Error>
65        where
66            Name: TryInto<&'a PartialNameRef, Error = E>,
67            crate::name::Error: From<E>,
68        {
69            todo!()
70            }
77    }
78}