Skip to content

Commit

Permalink
more doc
Browse files Browse the repository at this point in the history
  • Loading branch information
yegor256 committed Jan 14, 2023
1 parent 986f984 commit 7747d8a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/hex.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,13 +100,21 @@ impl Hex {

/// Count, how many bytes are in there.
///
/// For example:
/// For example, an empty [`Hex`] has zero bytes:
///
/// ```
/// use sodg::Hex;
/// let d = Hex::empty();
/// assert_eq!(0, d.len());
/// ```
///
/// A non-empty [`Hex`] with an `i64` inside has eight bytes:
///
/// ```
/// use sodg::Hex;
/// let d = Hex::from(42);
/// assert_eq!(8, d.len());
/// ```
pub fn len(&self) -> usize {
match self {
Hex::Vector(x) => x.len(),
Expand Down
12 changes: 12 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,18 @@ pub struct Sodg {
/// Pretty much anything that the relay returns will be used
/// as a new search string, starting from the `v` vertex.
pub trait Relay {
/// A method to be called when the searching algorithm
/// fails to find the required attribute.
///
/// The method must accept three arguments:
/// 1) the ID of the vertex where the search algorithm found a problem,
/// 2) the head of the edge it is trying to find,
/// 3) the tail of the edge (may be empty).
///
/// The method must return a new locator, which the algorithm will use.
/// If it is just a string, it will be treated as a name of the attribute to
/// try instead. If it starts from `"ν"`, it is treated as an absolute
/// locator on the entire graph.
fn re(&self, v: u32, a: &str, b: &str) -> Result<String>;
}

Expand Down

0 comments on commit 7747d8a

Please sign in to comment.