-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c125547
commit 5c495b9
Showing
1 changed file
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") | ||
} | ||
} |