Struct Instance

Source
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

Source

pub async fn login_account( instance: Shared<Instance>, login_schema: LoginSchema, ) -> ChorusResult<ChorusUser>

Logs into an existing account on the spacebar server.

§Reference

See https://docs.spacebar.chat/routes/#post-/auth/login/

Source

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

Source

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

See https://docs.discord.food/authentication#send-mfa-sms

Source§

impl Instance

Source

pub async fn register_account( instance: Shared<Instance>, register_schema: RegisterSchema, ) -> ChorusResult<ChorusUser>

Registers a new user on the server.

§Reference

See https://docs.spacebar.chat/routes/#post-/auth/register/

Source§

impl Instance

Source

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

Source

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

Source

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

See https://docs.spacebar.chat/routes/#get-/ping/

Source

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

Source

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

Source

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

Source

pub async fn is_limited( api_url: &str, ) -> ChorusResult<Option<LimitsConfiguration>>

Source

pub async fn detect_software(&mut self) -> InstanceSoftware

Detects which InstanceSoftware the instance is running.

Source

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.

Source

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.

Source

pub fn software(&self) -> InstanceSoftware

Returns which InstanceSoftware the instance is running.

Source

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.

Trait Implementations§

Source§

impl Clone for Instance

Source§

fn clone(&self) -> Instance

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

impl Debug for Instance

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Instance

Source§

fn default() -> Instance

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Instance

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Instance

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> IntoShared for T

Source§

fn into_shared(self) -> Arc<RwLock<T>>

Uses Shared to provide an ergonomic alternative to Arc::new(RwLock::new(obj)). Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

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

Source§

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

Source§

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

Source§

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

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,