pub struct Config { /* private fields */ }Implementations§
Source§impl Config
impl Config
pub fn default_server_name(&self) -> Option<&str>
Sourcepub fn add_server(
&mut self,
host: String,
protocol: String,
ecdsa_public_key: Option<String>,
nickname: Option<String>,
) -> Result<()>
pub fn add_server( &mut self, host: String, protocol: String, ecdsa_public_key: Option<String>, nickname: Option<String>, ) -> Result<()>
Add a ServerConfig to the home configuration.
Returns an Err on name conflict,
i.e. if a ServerConfig with the nickname or host already exists.
Callers should call Config::save afterwards
to ensure modifications are persisted to disk.
Sourcepub fn set_default_server(
&mut self,
nickname_or_host_or_url: &str,
) -> Result<()>
pub fn set_default_server( &mut self, nickname_or_host_or_url: &str, ) -> Result<()>
Set the default server in the home configuration.
Returns an Err if nickname_or_host_or_url
does not refer to an existing ServerConfig
in the home configuration.
Callers should call Config::save afterwards
to ensure modifications are persisted to disk.
Sourcepub fn remove_server(&mut self, nickname_or_host_or_url: &str) -> Result<()>
pub fn remove_server(&mut self, nickname_or_host_or_url: &str) -> Result<()>
Delete a ServerConfig from the home configuration.
Returns an Err if nickname_or_host_or_url
does not refer to an existing ServerConfig
in the home configuration.
Callers should call Config::save afterwards
to ensure modifications are persisted to disk.
Sourcepub fn get_host_url(&self, server: Option<&str>) -> Result<String>
pub fn get_host_url(&self, server: Option<&str>) -> Result<String>
Get a URL for the specified server.
Returns the URL of the default server if server is None.
If server is Some and is a complete URL,
including protocol and hostname,
returns that URL without accessing the configuration.
Returns an Err if:
serverisSome, but not a complete URL, and the supplied name does not refer to any server in the configuration.serverisNone, but the configuration does not have a default server.
Sourcepub fn host<'a>(&'a self, server: Option<&'a str>) -> Result<&'a str>
pub fn host<'a>(&'a self, server: Option<&'a str>) -> Result<&'a str>
Get the hostname of the specified server.
Returns the hostname of the default server if server is None.
If server is Some and is a complete URL,
including protocol and hostname,
returns that hostname without accessing the configuration.
Returns an Err if:
serverisSome, but not a complete URL, and the supplied name does not refer to any server in the configuration.serverisNone, but the configuration does not have a default server.
Sourcepub fn protocol<'a>(&'a self, server: Option<&'a str>) -> Result<&'a str>
pub fn protocol<'a>(&'a self, server: Option<&'a str>) -> Result<&'a str>
Get the protocol of the specified server, either "http" or "https".
Returns the protocol of the default server if server is None.
If server is Some and is a complete URL,
including protocol and hostname,
returns that protocol without accessing the configuration.
In that case, the protocol is not validated.
Returns an Err if:
serverisSome, but not a complete URL, and the supplied name does not refer to any server in the configuration.serverisNone, but the configuration does not have a default server.
pub fn server_configs(&self) -> &[ServerConfig]
pub fn load(home_path: CliTomlPath) -> Result<Self>
pub fn save(&self)
pub fn server_decoding_key(&self, server: Option<&str>) -> Result<DecodingKey>
pub fn server_nick_or_host<'a>( &'a self, server: Option<&'a str>, ) -> Result<&'a str>
pub fn server_fingerprint(&self, server: Option<&str>) -> Result<Option<&str>>
pub fn set_server_fingerprint( &mut self, server: Option<&str>, new_fingerprint: String, ) -> Result<()>
pub fn edit_server( &mut self, server: &str, new_nickname: Option<&str>, new_host: Option<&str>, new_protocol: Option<&str>, ) -> Result<(Option<String>, Option<String>, Option<String>)>
pub fn delete_server_fingerprint(&mut self, server: Option<&str>) -> Result<()>
pub fn set_web_session_token(&mut self, token: String)
pub fn set_spacetimedb_token(&mut self, token: String)
pub fn clear_login_tokens(&mut self)
pub fn web_session_token(&self) -> Option<&String>
pub fn spacetimedb_token(&self) -> Option<&String>
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Config
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
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
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>
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