docs: More docs and improvements of existing docs

- Tried not to leave a single public function undocumented, though did not double-document public function with obvious names
- Remove all mentions of the strategy selector in favour of the strategy registry (to avoid confusion)
This commit is contained in:
TAMARA LIPOWSKI
2025-02-05 16:35:43 -05:00
parent 44e8e0bb96
commit 07457b5f76
10 changed files with 43 additions and 14 deletions

View File

@@ -4,6 +4,7 @@ use crate::encoding::{
swap_encoder::SwapEncoder,
};
/// Builds a `SwapEncoder` for the given protocol system and executor address.
pub struct SwapEncoderBuilder {
protocol_system: String,
executor_address: String,

View File

@@ -7,12 +7,16 @@ use crate::encoding::{
swap_encoder::SwapEncoder,
};
/// Registry containing all supported `SwapEncoders`.
#[derive(Clone)]
pub struct SwapEncoderRegistry {
/// A hashmap containing the protocol system as a key and the `SwapEncoder` as a value.
encoders: HashMap<String, Box<dyn SwapEncoder>>,
}
impl SwapEncoderRegistry {
/// Populates the registry with the `SwapEncoders` for the given blockchain by parsing the
/// executors in the file at the given path.
pub fn new(executors_file_path: &str, blockchain: Chain) -> Result<Self, EncodingError> {
let config_str = fs::read_to_string(executors_file_path)?;
let config: HashMap<Chain, HashMap<String, String>> = serde_json::from_str(&config_str)?;