Skip to content

Commit a8d9a24

Browse files
committed
docs: Add more documentation to OdbBackend
Added more documentation to clarify how to do error handling properly. Clarified the default behaviour of `OdbBackend::exists`.
1 parent 9600f96 commit a8d9a24

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/odb_backend.rs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,18 @@ use std::{ptr, slice};
1111

1212
/// A custom implementation of an [`Odb`] backend.
1313
///
14-
/// # Errors
14+
/// Most of the default implementations of this trait's methods panic when called as they are
15+
/// intended to be overridden.
1516
///
16-
/// If the backend does not have enough memory, the error code should be
17-
/// [`ErrorCode::GenericError`] and the class should be [`ErrorClass::NoMemory`].
17+
/// # Error recommendations
18+
///
19+
/// Errors are generally left at the implementation's discretion; some recommendations are
20+
/// made regarding error codes and classes to ease implementation and usage of custom backends.
21+
///
22+
/// Read the individual methods' documentation for more specific recommendations.
23+
///
24+
/// If the backend does not have enough memory, the error SHOULD be code
25+
/// [`ErrorCode::GenericError`] and the class SHOULD be [`ErrorClass::NoMemory`].
1826
#[allow(unused_variables)]
1927
pub trait OdbBackend {
2028
/// Returns the supported operations of this backend.
@@ -163,6 +171,8 @@ pub trait OdbBackend {
163171
/// Requires that [`SupportedOperations::EXISTS`] is present in the value returned from
164172
/// [`supported_operations`] to expose it to libgit2.
165173
///
174+
/// The default implementation of this method panics.
175+
///
166176
/// # Implementation notes
167177
///
168178
/// An implementation SHOULD return `Ok(true)` if the object exists, and `Ok(false)` if the

0 commit comments

Comments
 (0)