pub struct ModuleContext {
pub module_id: String,
pub socket_path: String,
pub data_dir: String,
pub config: HashMap<String, String>,
}Expand description
Context provided to modules for communication with node
This is the interface modules use to communicate with the base node. All communication goes through IPC, so this is essentially a handle to the IPC connection.
Fields§
§module_id: StringModule ID (unique identifier for this module instance)
socket_path: StringIPC socket path (Unix domain socket path for communication)
data_dir: StringModule data directory (where module can store its state)
config: HashMap<String, String>Module configuration (key-value pairs from config file)
Implementations§
Source§impl ModuleContext
impl ModuleContext
Sourcepub fn new(
module_id: String,
socket_path: String,
data_dir: String,
config: HashMap<String, String>,
) -> ModuleContext
pub fn new( module_id: String, socket_path: String, data_dir: String, config: HashMap<String, String>, ) -> ModuleContext
Create a new module context
Sourcepub fn get_config(&self, key: &str) -> Option<&String>
pub fn get_config(&self, key: &str) -> Option<&String>
Get a configuration value
Sourcepub fn get_config_or(&self, key: &str, default: &str) -> String
pub fn get_config_or(&self, key: &str, default: &str) -> String
Get a configuration value with default
Trait Implementations§
Source§impl Clone for ModuleContext
impl Clone for ModuleContext
Source§fn clone(&self) -> ModuleContext
fn clone(&self) -> ModuleContext
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for ModuleContext
impl RefUnwindSafe for ModuleContext
impl Send for ModuleContext
impl Sync for ModuleContext
impl Unpin for ModuleContext
impl UnsafeUnpin for ModuleContext
impl UnwindSafe for ModuleContext
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more