pub struct CliContext<'a> { /* private fields */ }Expand description
The resolved inputs a console command runs against.
Implementations§
Source§impl<'a> CliContext<'a>
impl<'a> CliContext<'a>
Sourcepub fn new(env: &'a dyn EnvVars) -> Self
pub fn new(env: &'a dyn EnvVars) -> Self
A context over env with no CLI overrides (env + defaults only).
Sourcepub fn with_database(self, database: impl Into<String>) -> Self
pub fn with_database(self, database: impl Into<String>) -> Self
Set the --database override (highest-precedence layer).
Sourcepub fn with_chain_id(self, chain_id: impl Into<String>) -> Self
pub fn with_chain_id(self, chain_id: impl Into<String>) -> Self
Set the --chain-id override.
Sourcepub fn with_node_http(self, uri: impl Into<String>) -> Self
pub fn with_node_http(self, uri: impl Into<String>) -> Self
Set the --node-http override.
Sourcepub fn with_node_ws(self, uri: impl Into<String>) -> Self
pub fn with_node_ws(self, uri: impl Into<String>) -> Self
Set the --node-ws override.
Sourcepub fn database_override(&self) -> Option<&str>
pub fn database_override(&self) -> Option<&str>
The --database override, if any.
Sourcepub fn database_path(&self) -> Resolved<PathBuf>
pub fn database_path(&self) -> Resolved<PathBuf>
Resolve the database path: --database > DEGENBOT_DB_PATH > the
built-in default. Never fails.
Sourcepub fn chain_id(&self) -> Result<Resolved<u64>, ConfigError>
pub fn chain_id(&self) -> Result<Resolved<u64>, ConfigError>
Resolve the session chain id: --chain-id > DEGENBOT_DEFAULT_CHAIN_ID.
§Errors
degenbot_config::ConfigError when neither layer supplied a value, or
the winning layer is not an integer.
Sourcepub fn node_http_uri_for(
&self,
chain_id: u64,
) -> Result<Resolved<String>, ConfigError>
pub fn node_http_uri_for( &self, chain_id: u64, ) -> Result<Resolved<String>, ConfigError>
Resolve the HTTP node URI for chain_id: --node-http >
DEGENBOT_RPC_HTTP_CHAINID_<id>.
The updater arms resolve the chain they actually operate on (which may differ from the session chain id, e.g. a validated Aave deployment).
§Errors
degenbot_config::ConfigError when no layer supplied the URI.
Sourcepub fn node_http_uri(&self) -> Result<Resolved<String>, ConfigError>
pub fn node_http_uri(&self) -> Result<Resolved<String>, ConfigError>
Resolve the HTTP node URI for the session chain id.
§Errors
degenbot_config::ConfigError when the chain id or endpoint is
unresolved.
Sourcepub fn node_uris(&self) -> Result<ResolvedNodeUris, ConfigError>
pub fn node_uris(&self) -> Result<ResolvedNodeUris, ConfigError>
Resolve both node URIs for the session chain id.
§Errors
degenbot_config::ConfigError when the chain id or either endpoint is
unresolved.
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for CliContext<'a>
impl<'a> !Send for CliContext<'a>
impl<'a> !Sync for CliContext<'a>
impl<'a> !UnwindSafe for CliContext<'a>
impl<'a> Freeze for CliContext<'a>
impl<'a> Unpin for CliContext<'a>
impl<'a> UnsafeUnpin for CliContext<'a>
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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> ⓘ
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> ⓘ
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