From e2d4cf8dfb5f595f9f1319676eadf885724eceeb Mon Sep 17 00:00:00 2001 From: Arun Jangra Date: Thu, 27 Jun 2024 00:48:52 +0530 Subject: [PATCH] feat : added comments for functions and impls as suggested by deepsource --- crates/orchestrator/src/data_storage/aws_s3/config.rs | 3 +++ crates/orchestrator/src/data_storage/aws_s3/mod.rs | 7 +++++++ crates/orchestrator/src/data_storage/mod.rs | 4 ++++ crates/orchestrator/src/data_storage/types.rs | 3 +++ 4 files changed, 17 insertions(+) diff --git a/crates/orchestrator/src/data_storage/aws_s3/config.rs b/crates/orchestrator/src/data_storage/aws_s3/config.rs index 28e8aa54..949f98db 100644 --- a/crates/orchestrator/src/data_storage/aws_s3/config.rs +++ b/crates/orchestrator/src/data_storage/aws_s3/config.rs @@ -2,6 +2,7 @@ use utils::env_utils::get_env_var_or_panic; use crate::data_storage::DataStorageConfig; +/// Represents AWS S3 config struct with all the necessary variables. pub struct AWSS3Config { pub s3_key_id: String, pub s3_key_secret: String, @@ -9,7 +10,9 @@ pub struct AWSS3Config { pub s3_bucket_region: String, } +/// Implementation of `DataStorageConfig` for `AWSS3Config` impl DataStorageConfig for AWSS3Config { + /// To return the config struct by creating it from the environment variables. fn new_from_env() -> Self { Self { s3_key_id: get_env_var_or_panic("AWS_ACCESS_KEY_ID"), diff --git a/crates/orchestrator/src/data_storage/aws_s3/mod.rs b/crates/orchestrator/src/data_storage/aws_s3/mod.rs index 7420a0b0..f99d3d67 100644 --- a/crates/orchestrator/src/data_storage/aws_s3/mod.rs +++ b/crates/orchestrator/src/data_storage/aws_s3/mod.rs @@ -6,14 +6,21 @@ use aws_sdk_s3::primitives::ByteStream; use aws_sdk_s3::{Client, Error}; use bytes::Bytes; +/// Module for AWS S3 config structs and implementations pub mod config; +/// AWSS3 represents AWS S3 client object containing the client and the config itself. pub struct AWSS3 { client: Client, config: AWSS3Config, } +/// Implementation for AWS S3 client. Contains the function for : +/// +/// - initializing a new AWS S3 client impl AWSS3 { + /// Initializes a new AWS S3 client by passing the config + /// and returning it. #[allow(dead_code)] pub async fn new(config: AWSS3Config) -> Self { // AWS cred building diff --git a/crates/orchestrator/src/data_storage/mod.rs b/crates/orchestrator/src/data_storage/mod.rs index 32bb43c9..3dbef150 100644 --- a/crates/orchestrator/src/data_storage/mod.rs +++ b/crates/orchestrator/src/data_storage/mod.rs @@ -21,6 +21,10 @@ pub trait DataStorage: Send + Sync { async fn put_data(&self, data: ByteStream, key: &str) -> Result<(), Error>; } +/// **DataStorageConfig** : Trait method to represent the config struct needed for +/// initialisation of data storage client pub trait DataStorageConfig { + /// Get a config file from environment vars in system or + /// dotenv file. fn new_from_env() -> Self; } diff --git a/crates/orchestrator/src/data_storage/types.rs b/crates/orchestrator/src/data_storage/types.rs index 11b3ea15..0fc1a6fb 100644 --- a/crates/orchestrator/src/data_storage/types.rs +++ b/crates/orchestrator/src/data_storage/types.rs @@ -2,6 +2,8 @@ use cairo_vm::Felt252; use serde::{Deserialize, Serialize}; use std::collections::HashMap; +/// This struct represents the contract changes that will be in `StarknetOsOutput` +/// as a vector. #[derive(Debug, Deserialize, Serialize)] pub struct ContractChanges { /// The address of the contract. @@ -14,6 +16,7 @@ pub struct ContractChanges { pub storage_changes: HashMap, } +/// This struct represents the starknet OS outputs in the json we will get after the run. #[derive(Debug, Deserialize, Serialize)] pub struct StarknetOsOutput { /// The root before.