Struct spacetimedb_cli::Config

source ·
pub struct Config { /* private fields */ }

Implementations§

source§

impl Config

source

pub fn default_server_name(&self) -> Option<&str>

source

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.

source

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.

source

pub fn remove_server( &mut self, nickname_or_host_or_url: &str, delete_identities: bool ) -> Result<Vec<IdentityConfig>>

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.

If delete_identities is true, also removes any saved IdentityConfigs which apply to the removed server. This requires that the server have a saved fingerprint.

Callers should call Config::save afterwards to ensure modifications are persisted to disk.

source

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.

Entries in the project configuration supersede entries in the home configuration.

If server is Some and is a complete URL, including protocol and hostname, returns that URL without accessing the configuration.

Returns an Err if:

  • server is Some, but not a complete URL, and the supplied name does not refer to any server in either the project or the home configuration.
  • server is None, but neither the home nor the project configuration has a default server.
source

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.

Entries in the project configuration supersede entries in the home configuration.

If server is Some and is a complete URL, including protocol and hostname, returns that hostname without accessing the configuration.

Returns an Err if:

  • server is Some, but not a complete URL, and the supplied name does not refer to any server in either the project or the home configuration.
  • server is None, but neither the home nor the project configuration has a default server.
source

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.

Entries in the project configuration supersede entries in the home configuration.

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:

  • server is Some, but not a complete URL, and the supplied name does not refer to any server in either the project or the home configuration.
  • server is None, but neither the home nor the project configuration has a default server.
source

pub fn default_identity(&self, server: Option<&str>) -> Result<&str>

source

pub fn set_default_identity( &mut self, default_identity: String, server: Option<&str> ) -> Result<()>

Set the default identity for server in the home configuration.

Does not validate that default_identity applies to server.

Returns an Err if:

  • server is Some, but does not refer to any server in the home configuration.
  • server is None, but the home configuration does not have a default server.
source

pub fn set_identity_nickname( &mut self, identity: &Identity, nickname: &str ) -> Result<Option<String>, Error>

Sets the nickname for the provided identity.

If the identity already has a nickname set, it will be overwritten and returned. If the identity is not found, an error will be returned.

§Returns
  • Ok(Option<String>) - If the identity was found, the old nickname will be returned.
  • Err(anyhow::Error) - If the identity was not found.
source

pub fn identity_configs(&self) -> &[IdentityConfig]

source

pub fn identity_configs_mut(&mut self) -> &mut Vec<IdentityConfig>

source

pub fn server_configs(&self) -> &[ServerConfig]

source

pub fn load() -> Self

source

pub fn new_with_localhost() -> Self

source

pub fn save(&self)

source

pub fn get_default_identity_config( &self, server: Option<&str> ) -> Result<&IdentityConfig>

source

pub fn name_exists(&self, nickname: &str) -> bool

source

pub fn get_identity_config_by_name(&self, name: &str) -> Option<&IdentityConfig>

source

pub fn get_identity_config_by_identity( &self, identity: &Identity ) -> Option<&IdentityConfig>

source

pub fn get_identity_config_by_identity_mut( &mut self, identity: &Identity ) -> Option<&mut IdentityConfig>

source

pub fn resolve_name_to_identity( &self, identity_or_name: &str ) -> Result<Identity>

Converts some given identity_or_name into an identity.

If identity_or_name is None then None is returned. If identity_or_name is Some, then if its an identity then its just returned. If its not an identity it is assumed to be a name and it is looked up as an identity nickname. If the identity exists it is returned, otherwise we panic.

source

pub fn get_identity_config( &self, identity_or_name: &str ) -> Option<&IdentityConfig>

Converts some given identity_or_name into an IdentityConfig.

§Returns
  • None - If an identity config with the given identity_or_name does not exist.
  • Some - A mutable reference to the IdentityConfig with the given identity_or_name.
source

pub fn get_identity_config_mut( &mut self, identity_or_name: &str ) -> Option<&mut IdentityConfig>

Converts some given identity_or_name into a mutable IdentityConfig.

§Returns
  • None - If an identity config with the given identity_or_name does not exist.
  • Some - A mutable reference to the IdentityConfig with the given identity_or_name.
source

pub fn delete_identity_config_by_name( &mut self, name: &str ) -> Option<IdentityConfig>

source

pub fn delete_identity_config_by_identity( &mut self, identity: &Identity ) -> Option<IdentityConfig>

source

pub fn delete_all_identity_configs(&mut self)

Deletes all stored identity configs. This function does not save the config after removing all configs.

source

pub fn update_all_default_identities(&mut self)

source

pub fn set_default_identity_if_unset( &mut self, server: Option<&str>, identity: &str ) -> Result<()>

source

pub fn server_decoding_key(&self, server: Option<&str>) -> Result<DecodingKey>

source

pub fn server_nick_or_host<'a>( &'a self, server: Option<&'a str> ) -> Result<&'a str>

source

pub fn server_fingerprint(&self, server: Option<&str>) -> Result<Option<&str>>

source

pub fn set_server_fingerprint( &mut self, server: Option<&str>, new_fingerprint: String ) -> Result<()>

source

pub fn remove_identities_for_server( &mut self, server: Option<&str> ) -> Result<Vec<IdentityConfig>>

source

pub fn remove_identities_for_fingerprint( &mut self, fingerprint: &str ) -> Result<Vec<IdentityConfig>>

source

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>)>

source

pub fn delete_server_fingerprint(&mut self, server: Option<&str>) -> Result<()>

Trait Implementations§

source§

impl Clone for Config

source§

fn clone(&self) -> Config

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

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> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> FromRef<T> for T
where T: Clone,

source§

fn from_ref(input: &T) -> T

Converts to this type from a reference to the input type.
source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> IntoEither for T

source§

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 more
source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
source§

impl<T> Pointable for T

source§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

source§

fn vzip(self) -> V

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more