pub struct Instance {
pub urls: UrlBundle,
pub instance_info: GeneralConfiguration,
pub limits_information: Option<LimitsInformation>,
pub client: Client,
pub default_gateway_events: Events,
/* private fields */
}
Expand description
Represents a Spacebar-compatible Instance
.
This struct is most commonly used for Instance::login_account
,
Instance::login_with_token
and Instance::register_account
.
If limits_information
is None
, then the instance will not be rate limited.
Fields§
§urls: UrlBundle
The URLs of the instance
instance_info: GeneralConfiguration
General information about the instance, including its name, description, image, …
(This is set by the instance admins)
limits_information: Option<LimitsInformation>
Ratelimit information about the instance.
If this field is None
, then the instance will not be rate limited.
client: Client
The reqwest HTTP request client
default_gateway_events: Events
The default gateway Events
new gateway connections will inherit.
This field can be used to subscribe to events that are received before we get access to the gateway handle object on new ChorusUsers created with Instance::login_account, Instance::login_with_token and Instance::register_account
Implementations§
Source§impl Instance
impl Instance
Sourcepub async fn login_account(
instance: Shared<Instance>,
login_schema: LoginSchema,
) -> ChorusResult<ChorusUser>
pub async fn login_account( instance: Shared<Instance>, login_schema: LoginSchema, ) -> ChorusResult<ChorusUser>
Logs into an existing account on the spacebar server.
§Reference
Sourcepub async fn verify_mfa_login(
instance: Shared<Instance>,
authenticator: MfaAuthenticationType,
schema: VerifyMFALoginSchema,
) -> ChorusResult<ChorusUser>
pub async fn verify_mfa_login( instance: Shared<Instance>, authenticator: MfaAuthenticationType, schema: VerifyMFALoginSchema, ) -> ChorusResult<ChorusUser>
Verifies a multi-factor authentication login
§Reference
See https://docs.discord.food/authentication#verify-mfa-login
Sourcepub async fn send_mfa_sms(
&mut self,
schema: SendMfaSmsSchema,
) -> ChorusResult<SendMfaSmsResponse>
pub async fn send_mfa_sms( &mut self, schema: SendMfaSmsSchema, ) -> ChorusResult<SendMfaSmsResponse>
Sends a multi-factor authentication code to the user’s phone number
§Reference
Source§impl Instance
impl Instance
Sourcepub async fn register_account(
instance: Shared<Instance>,
register_schema: RegisterSchema,
) -> ChorusResult<ChorusUser>
pub async fn register_account( instance: Shared<Instance>, register_schema: RegisterSchema, ) -> ChorusResult<ChorusUser>
Registers a new user on the server.
§Reference
Source§impl Instance
impl Instance
Sourcepub async fn login_with_token(
instance: Shared<Instance>,
token: &str,
) -> ChorusResult<ChorusUser>
pub async fn login_with_token( instance: Shared<Instance>, token: &str, ) -> ChorusResult<ChorusUser>
Logs into an existing account on the spacebar server, using only a token.
Source§impl Instance
impl Instance
Sourcepub async fn general_configuration_schema(
&mut self,
) -> ChorusResult<GeneralConfiguration>
pub async fn general_configuration_schema( &mut self, ) -> ChorusResult<GeneralConfiguration>
Gets the instance policies schema.
§Notes
This is a Spacebar only endpoint.
§Reference
See https://docs.spacebar.chat/routes/#get-/policies/instance/
Source§impl Instance
impl Instance
Sourcepub async fn ping(&mut self) -> ChorusResult<PingReturn>
pub async fn ping(&mut self) -> ChorusResult<PingReturn>
Pings the instance, also fetches instance info.
See: PingReturn
§Notes
This is a Spacebar only endpoint.
§Reference
Sourcepub async fn get_version(&mut self) -> ChorusResult<VersionReturn>
pub async fn get_version(&mut self) -> ChorusResult<VersionReturn>
Fetches the instance’s software implementation and version.
See: VersionReturn
§Notes
This is a Symfonia only endpoint. (For now, we hope that spacebar will adopt it as well)
Source§impl Instance
impl Instance
Sourcepub async fn from_url_bundle(
urls: UrlBundle,
options: Option<GatewayOptions>,
) -> ChorusResult<Instance>
pub async fn from_url_bundle( urls: UrlBundle, options: Option<GatewayOptions>, ) -> ChorusResult<Instance>
Creates a new Instance
from the relevant instance urls.
If options
is None
, the default GatewayOptions
will be used.
To create an Instance from one singular url, use Instance::new()
.
Sourcepub async fn new(
root_url: &str,
options: Option<GatewayOptions>,
) -> ChorusResult<Instance>
pub async fn new( root_url: &str, options: Option<GatewayOptions>, ) -> ChorusResult<Instance>
Creates a new Instance
by trying to get the relevant instance urls from a root url.
If options
is None
, the default GatewayOptions
will be used.
Shorthand for Instance::from_url_bundle(UrlBundle::from_root_domain(root_domain).await?)
.
pub async fn is_limited( api_url: &str, ) -> ChorusResult<Option<LimitsConfiguration>>
Sourcepub async fn detect_software(&mut self) -> InstanceSoftware
pub async fn detect_software(&mut self) -> InstanceSoftware
Detects which InstanceSoftware the instance is running.
Sourcepub fn gateway_options(&self) -> GatewayOptions
pub fn gateway_options(&self) -> GatewayOptions
Returns the GatewayOptions
the instance uses when spawning new connections.
These options are used on the gateways created when logging in and registering.
Sourcepub fn set_gateway_options(&mut self, options: GatewayOptions)
pub fn set_gateway_options(&mut self, options: GatewayOptions)
Manually sets the GatewayOptions
the instance should use when spawning new connections.
These options are used on the gateways created when logging in and registering.
Sourcepub fn software(&self) -> InstanceSoftware
pub fn software(&self) -> InstanceSoftware
Returns which InstanceSoftware
the instance is running.
Sourcepub fn set_software(&mut self, software: InstanceSoftware)
pub fn set_software(&mut self, software: InstanceSoftware)
Manually sets which InstanceSoftware
the instance is running.
Note: you should only use this if you are absolutely sure about an instance (e. g. you run it). If set to an incorrect value, this may cause unexpected errors or even undefined behaviours.
Manually setting the software is generally discouraged. Chorus should automatically detect which type of software the instance is running.