// Copyright © 2022 The Radicle Link Contributors // SPDX-License-Identifier: GPL-3.0-or-later use std::error::Error; use git_ext::{ ref_format::{refspec, RefStr}, Oid, }; use super::Reference; /// Read-only access to a git refdb. /// /// See [`crate::Read`] for an implementation of this trait. pub trait Read { /// The error type for finding a reference in the refdb. type FindRef: Error + Send + Sync + 'static; /// The error type for finding references in the refdb. type FindRefs: Error + Send + Sync + 'static; /// The error type for finding reference Oid in the refdb. type FindRefOid: Error + Send + Sync + 'static; /// Iterator for references returned by `find_references`. type References: Iterator>; /// Find the reference that corresponds to `name`. If the reference does not /// exist, then `None` is returned. fn find_reference(&self, name: Ref) -> Result, Self::FindRef> where Ref: AsRef; /// Find the references that match `pattern`. fn find_references(&self, pattern: Pat) -> Result where Pat: AsRef; /// Find the [`Oid`] for the reference that corresponds to `name`. If the /// reference does not exist, then `None` is returned. fn find_reference_oid(&self, name: Ref) -> Result, Self::FindRefOid> where Ref: AsRef; }