Skip to content

Commit

Permalink
Improve docs on the translator/translate traits
Browse files Browse the repository at this point in the history
  • Loading branch information
tcharding authored and sanket1729 committed Jun 7, 2022
1 parent fca7d9d commit a086861
Showing 1 changed file with 6 additions and 10 deletions.
16 changes: 6 additions & 10 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,8 @@ impl hash::Hash for DummySha256Hash {
}
}

/// Provides the conversion information required in [`TranslatePk`]
/// Describes an object that can translate various keys and hashes from one key to the type
/// associated with the other key. Used by the [`TranslatePk`] trait to do the actual translations.
pub trait Translator<P, Q, E>
where
P: MiniscriptKey,
Expand Down Expand Up @@ -440,12 +441,8 @@ where
}
}

/// Converts a descriptor using abstract keys to one using specific keys.
///
/// # Panics
///
/// If `fpk` returns an uncompressed key when converting to a segwit descriptor.
/// To prevent this panic, ensure `fpk` returns an error in this case instead.
/// Converts a descriptor using abstract keys to one using specific keys. Uses translator `t` to do
/// the actual translation function calls.
pub trait TranslatePk<P, Q>
where
P: MiniscriptKey,
Expand All @@ -454,9 +451,8 @@ where
/// The associated output type. This must be `Self<Q>`.
type Output;

/// Translates a struct from one generic to another where the translation
/// for Pk is provided by function `fpk`, and translation for PkH is
/// provided by function `fpkh`.
/// Translates a struct from one generic to another where the translations
/// for Pk are provided by the given [`Translator`].
fn translate_pk<T, E>(&self, translator: &mut T) -> Result<Self::Output, E>
where
T: Translator<P, Q, E>;
Expand Down

0 comments on commit a086861

Please sign in to comment.