Skip to content

Commit

Permalink
add untracked file
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgeantonio21 committed Apr 12, 2024
1 parent c125547 commit 5c495b9
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions atoma-event-subscribe/sui/src/config.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
use std::path::Path;

use config::Config;
use serde::Deserialize;
use sui_sdk::types::base_types::ObjectID;

#[derive(Debug, Deserialize)]
pub struct SuiSubscriberConfig {
http_url: String,
ws_url: String,
object_id: ObjectID,
}

impl SuiSubscriberConfig {
pub fn new(http_url: String, ws_url: String, object_id: ObjectID) -> Self {
Self {
http_url,
ws_url,
object_id,
}
}

pub fn http_url(&self) -> String {
self.http_url.clone()
}

pub fn ws_url(&self) -> String {
self.ws_url.clone()
}

pub fn object_id(&self) -> ObjectID {
self.object_id
}

pub fn from_file_path<P: AsRef<Path>>(config_file_path: P) -> Self {
let builder = Config::builder().add_source(config::File::with_name(
config_file_path.as_ref().to_str().unwrap(),
));
let config = builder
.build()
.expect("Failed to generate inference configuration file");
config
.try_deserialize::<Self>()
.expect("Failed to generated config file")
}
}

0 comments on commit 5c495b9

Please sign in to comment.