chorus/README.md

172 lines
7.6 KiB
Markdown
Raw Permalink Normal View History

2023-04-15 18:33:17 +02:00
<div align="center">
2023-04-10 21:28:22 +02:00
2023-05-25 18:33:17 +02:00
[![Discord]][Discord-invite]
2023-04-10 21:37:27 +02:00
[![Build][build-shield]][build-url]
[![Coverage][coverage-shield]][coverage-url]
2023-08-27 13:21:45 +02:00
<img src="https://img.shields.io/static/v1?label=Status&message=Alpha&color=blue">
2023-04-10 21:31:40 +02:00
2023-04-15 18:33:17 +02:00
</br>
<div align="center">
<a href="https://github.com/polyphony-chat/chorus">
2023-11-25 13:26:24 +01:00
<img src="https://github.com/polyphony-chat/branding/blob/main/logos/polyphony-chorus-round-8bit.png?raw=true" alt="The chorus logo. a dark, square background with rounded edges. on this background, there are three vertically stacked, purple lines. The lines each resemble a sine curve." width="128" height="128">
2023-04-15 18:33:17 +02:00
</a>
<h3 align="center">Chorus</h3>
<p align="center">
<br />
<a href="https://docs.rs/chorus/latest/chorus/"><strong>Explore the docs »</strong></a>
2023-04-15 18:33:17 +02:00
<br />
<br />
<a href="https://github.com/polyphony-chat/chorus/issues">Report Bug</a>
·
<a href="https://crates.io/crates/chorus">crates.io</a>
2023-04-26 11:19:04 +02:00
·
<a href="https://discord.gg/8tKSC8wzDq">Join Discord</a>
2023-04-15 18:33:17 +02:00
</p>
</div>
</div>
2023-04-10 21:28:22 +02:00
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
Chorus is a Rust library which poses as an API wrapper for [Spacebar Chat](https://github.com/spacebarchat/),
Discord and our own Polyphony. Its high-level API is designed to be easy to use, while still providing the
flexibility one would expect from a library like this.
You can establish as many connections to as many servers as you want, and you can use them all at the same time.
2023-06-20 00:17:52 +02:00
## A Tour of Chorus
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
Chorus combines all the required functionalities of an API wrapper for chat services into one modular library.
The library handles various aspects on your behalf, such as rate limiting, authentication and maintaining
a WebSocket connection to the Gateway. This means that you can focus on building your application,
instead of worrying about the underlying implementation details.
To get started with Chorus, import it into your project by adding the following to your `Cargo.toml` file:
```toml
[dependencies]
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
chorus = "0.16.0"
```
### Establishing a Connection
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
To connect to a Polyphony/Spacebar compatible server, you'll need to create an [`Instance`](https://docs.rs/chorus/latest/chorus/instance/struct.Instance.html) like this:
```rs
use chorus::instance::Instance;
#[tokio::main]
async fn main() {
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
let instance = Instance::new("https://example.com", None)
.await
.expect("Failed to connect to the Spacebar server");
// You can create as many instances of `Instance` as you want, but each `Instance` should likely be unique.
dbg!(instance.instance_info);
dbg!(instance.limits_information);
}
```
This Instance can now be used to log in, register and from there on, interact with the server in all sorts of ways.
### Logging In
Logging in correctly provides you with an instance of `ChorusUser`, with which you can interact with the server and
manipulate the account. Assuming you already have an account on the server, you can log in like this:
```rs
use chorus::types::LoginSchema;
// Assume, you already have an account created on this instance. Registering an account works
// the same way, but you'd use the Register-specific Structs and methods instead.
let login_schema = LoginSchema {
login: "user@example.com".to_string(),
password: "Correct-Horse-Battery-Staple".to_string(),
..Default::default()
};
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
// Each user connects to the Gateway. Each users' Gateway connection lives on a separate thread. Depending on
// the runtime feature you choose, this can potentially take advantage of all of your computers' threads.
let user = instance
.login_account(login_schema)
.await
.expect("An error occurred during the login process");
dbg!(user.belongs_to);
dbg!(&user.object.read().unwrap().username);
```
## Supported Platforms
All major desktop operating systems (Windows, macOS (aarch64/x86_64), Linux (aarch64/x86_64)) are supported.
`wasm32-unknown-unknown` is a supported compilation target on versions `0.12.0` and up. This allows you to use
Chorus in your browser, or in any other environment that supports WebAssembly.
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
To compile for `wasm32-unknown-unknown`, execute the following command:
```sh
cargo build --target=wasm32-unknown-unknown --no-default-features
```
The following features are supported on `wasm32-unknown-unknown`:
| Feature | WASM Support |
| ----------------- | ------------ |
| `client` | ✅ |
| `rt` | ✅ |
| `rt-multi-thread` | ❌ |
| `backend` | ❌ |
| `voice` | ❌ |
| `voice_udp` | ❌ |
| `voice_gateway` | ✅ |
We recommend checking out the "examples" directory, as well as the documentation for more information.
## MSRV (Minimum Supported Rust Version)
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
Rust **1.70.0**. This number might change at any point while Chorus is not yet at version 1.0.0.
## Development Setup
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
Make sure that you have at least Rust 1.70.0 installed. You can check your Rust version by running `cargo --version`
in your terminal. To compile for `wasm32-unknown-unknown`, you need to install the `wasm32-unknown-unknown` target.
You can do this by running `rustup target add wasm32-unknown-unknown`.
### Testing
In general, the tests will require you to run a local instance of the Spacebar server. You can find instructions on how
to do that [here](https://docs.spacebar.chat/setup/server/). You can find a pre-configured version of the server
[here](https://github.com/bitfl0wer/server). It is recommended to use the pre-configured version, as certain things
like "proxy connection checking" are already disabled on this version, which otherwise might break tests.
### wasm
To test for wasm, you will need to `cargo install wasm-pack`. You can then run
Primitive voice implementation (feature/voice) (#457) * Add Webrtc Identify & Ready * Add more webrtc typings * Attempt an untested voice gateway implementation * fmt * Merge with main * Same allow as for voice as normal gateway * Test error observer * Minor updates * More derives * Even more derives * Small types update * e * Minor doc fixes * Modernise voice gateway * Add default impl for voicegatewayerror * Make voice event fields pub * Event updates via the scientific method * ?? * Fix bad request in voice gateway init * Voice gateway updates * Fix error failing to 'deserialize' properly * Update voice identify * Clarify FIXME related to #430 * Update to v7 * Create seperate voice_gateway.rs and voice_udp.rs * Restructure voice to new module * fix: deserialization error in speaking bitflags * feat: kinda janky ip discovery impl * feat: return ip discovery data + minor update * feat: packet parsing! * fix: voice works again * feat: add voice_media_sink_wants (comitting uncommited changes to merge) * chore: rename events/webrtc to events/voice_gateway * Add UdpHandle * chore: clippy + other misc updates * fix: attempt to fix failing wasm build * chore: yes clippy, that is indeed an unneeded return statement * feat: add VoiceData struct * feat: add VoiceData reference to UdpHandler * feat: decryption? * chore: formatting * feat: add ssrc definition (op 12) * feat: add untested sending & asbtract nonce generation * feat: Public api! (sorta) * small updates * feat: add sequence number * chore: yes * feat: merge VoiceHandler into official development * chore: yes clippy, you are special * fix: duplicated gateway events * feat: first try at vgw wasm compat * fix: blunder * fix: gateway connect using wrong url * fix: properly using encrypted data, bad practice for buffer creation * chore: split voice udp * feat: udp error handling, create udp/backends * fix: its the same * chore: clarify UDP on WASM * api: split voice gateway and udp features, test for voice gateway in WASM * feat: new encryption modes, minor code quality * docs: document voice encryption modes * chore: unused imports * chore: update getrandom version to match wasm version * chore: update on packet size FIXME * drop buf asap * Okay can't do that actually * tests: add nonce test * normal tests work? * docs: fix doc warning, fix incorrect refrences to 'webrtc' * chore: json isn't a doc test * tests: better gateway auth test * testing tests * update voice heartbeat, fix the new test issue * committed too much * fix: unused import * fix: use ip discovery address as string, not as Vec<u8> * chore: less obnoxious logging * chore: better unimplemented voice modes handling * chore: remove unused variable * chore: use matches macro * add voice examples, make gateway ones clearer * rename voice example * chore: remove unused VoiceHandler * fix: implement gateway Reconnect and InvalidSession * Typo Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> * Fix a bunch of typos Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> * fix: error handling while loading native certs * fix: guh * use be for nonce bytes * fix: refactor gw and vgw closures * remove outdated docs --------- Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com>
2024-04-16 17:18:21 +02:00
`wasm-pack test --<chrome/firefox/safari> --headless -- --target wasm32-unknown-unknown --features="rt, client, voice_gateway" --no-default-features`
to run the tests for wasm.
## Versioning
This crate uses Semantic Versioning 2.0.0 as its versioning scheme. You can read the specification [here](https://semver.org/spec/v2.0.0.html).
2023-06-20 00:17:52 +02:00
## Contributing
See [CONTRIBUTING.md](./CONTRIBUTING.md).
2023-06-20 00:17:52 +02:00
🎉 Release 0.16.0 * add WebSocketEvent macro derive, bump chorus-macros to 0.3.0 (#490) * feat: add WebSocketEvent derive, bump to 0.2.1 * change license, version of macros * Use WebSocketEvent derive instead of impl WebSocketEvent for .. (#491) use derive macro instead of manual impl blocks * Move Shared<T> to types/mod.rs, bump some dependencies (#492) * deps: bump rustls to 0.21.11 This is done to fix CVE-2024-32650, which practically shouldn't affect us but it's still better not to use vulnerable dependencies. * deps: bump h2 to 0.3.26 This is done to fix another vulnerability, which should also not affect us (non-critical, in h2 servers) * fix: move Shared<T> to types/mod.rs * Reuse gateway backends, don't duplicate them for voice gateway (#493) * Refactor / fix login and register (#495) Change login and register to only use one ChorusUser object, change the api of related methods which were also somewhat ugly * Add the repository field to Cargo.toml * Ci improvements (#498) * bump wasm-bindgen version to 0.2.92 * change wasm-gecko to using ubuntu-latest, since geckodriver is not supported on macos-latest * check some common non-default feature configurations * add experimental semver checks * Update poem dependency * Convert timestamp fields to DateTime's * Feature lock different types for UserSettings::status * Make config register_configuration use Rights bitflag object * Update tests to use DateTime's for timestamps * Fix tests * Allow joined_at to default if field is not in responses. * Allow last_pin_timestamp to default if field is not in responses. * Remove serde(with) for message timestamps * Fix some iso timestamps being strings, not DateTime<Utc> (#499) * fix: some iso timestamps being strings * fix: register uses dates, not datetimes * Add sqlx::FromRow derive to GuildMember * remove dep: prefix in backend feature list * Implement sqlx Encode, Decode, Type for Rights bitflag object. * Use Snowflake in Claims * Use ChannelType enum on ChannelModifySchema * Feature lock Shared, so backend feature gets a facade type * Remove erroneous serde with attributes * Add From<Vec<GuildFeatures>> impl for GuildFeaturesList * Add feature sqlx locks for user, roles on GuildMember * Use distinct type for explicit_content_filter * Remove unused imports * Revert c4452132 * Remove final usages of erroneous serde impl * Fix errors in documentation tests * update dev-dependencies * actually fix linux tests * clear warnings * Update Cargo.lock * Expand documentation to explain facade type * Fix oversight for premium_since * Backend related updates (#501) (by Quat3rnion) Some updates relating to usage with Symfonia: * Using distinct types instead of primitives on some objects * Add sqlx derives and implementations * Make a facade type for Shared to be used in non-client contexts * Distinguish InviteType and InviteTargetType * Add sqlx Type, Encode, Decode impl for InviteFlags bitflag object. * Use distinct type `DefaultReaction` * Update fields for backend/sqlx compatibility. * Update derive for backend/sqlx compatibility. * Write custom serialize/deserialize impl's for InviteFlags * Clear warnings * Add InviteFlags::VIEWED * Remove double bound for E * Use distinct types in `InviteGuild` object. * Implement `From<Guild> for InviteGuild` * Add `GetInvitesSchema` * Add forgotten import and pub use. * Fix compile error * Update docs aesthetics Co-authored-by: kozabrada123 <59031733+kozabrada123@users.noreply.github.com> * Add type locks * Fix inverted type wrapping * Update Cargo.lock * Add SqlxBitFlags derive macro * Utilize new macros and use distinct Flag types * Add distinct MessageType enum * Fix error in macro * Make UserFlags deserialize from string * Add partial emoji and custom reaction types, refine SQLx mapping * Use chorus_macros from path, since it's there anyway * Fix test * Add forgotten feature locks * Remove unused imports, feature locks in macro * forgot a file :( * Feature lock the macro * Dirty hack * Fix test I feel silly. * Fix compilation for real, no dirty hack * Maybe fix tests, make UserFlags able to be deserialized from String or u64 * Add new SerdeBitFlags derive macro, to help reduce repetitive code * u8 -> u64 * Fix deserialization error w/ guild features list * chorus macros 0.4.0 * always update to latest release of macros * Update and add some types in support of the backend (#507) * Implement gateway options, zlib-stream compression (#508) * feat: add GatewayOptions * feat: implement zlib-stream compression This also changes how gateway messages work. Now each gateway backend converts its message into an intermediary RawGatewayMessage, from which we inflate and parse GatewayMessages. Thanks to ByteAlex and their zlib-stream-rs crate, which helped me understand how to parse a compressed websocket stream * Backend/guilds (#509) * Fix SQL encode/decode for GuildFeatures * Use distinct PermissionFlags type * Add Emoji schema types, modify GuildBan with feature lock * Add Schemas for pruning guild members * Add schemas for interfacing with stickers backend routes * Add schemas for interfacing with vanity-url backend routes * Add schema for interfacing with guilds/id/welcome-screen route * Make all Option<Vec> types Vec types with #[serde(default)] * Add various types to support guilds/* api routes * Add missing enums and structs for searching messages * Use proper distinct types * Add EmbedType enum * Use distinct PermissionFlags type * Changes supporting backend for VoiceState * Changes supporting backend for AuditLog's * Add custom deserializer for PermissionOverwriteType (#512) * Add custom deserializer for PermissionOverwriteType * Miscellaneous fixes (#514) - fix `PATCH /users/@me` - It incorrectly returned a required password error, even if the current password was set - fix `GET /users/@me/guilds` - It incorrectly sent body parameters instead of query ones - don't log debug! for every successful ratelimited request - use trace! so it's less spamy - update the max expected compression ratio (several times) from 20 to 200. let's hope that will be enough - fix deserialization errors relating to guild folders in user settings - fix a panic in `SqlxBitFlags` if there are extra flags. It now truncates them - update `chorus_macros` to 0.4.1 (due to the above fix) - log (trace!) event data if we fail to parse it or it's unrecognised, for debugging purposes - fix a deserialization error in the `MessageACK` event - fix `public_flags` in user objects not being `PublicFlags` bitflags * No openssl (#522) * Remove openssl from some packages' deps * Add shorthand wasm build script * Eliminate openssl dependency from crate * Build RootCertStore from webpki roots instead of native roots * Expand wasm documentation * Revert reqwest * Lock reqwest at 0.11.23 * Lock reqwest at 0.11.26, latest possible version * Add wasm test script * Replace `Observer` and `GatewayEvent` with `pubserve` crate * Fix voice, voice_udp features * Add one BILLION derives * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Provide alternative implementations for PartialEq for some types when sqlx feature is enabled * Fix: Wrong function name * Fix: Turn unconditional import of sqlx::types::Json into conditional one * Fix: Compile error with no default features * Update CONTRIBUTING.md * Use cargo nextest * Use cargo nextest * Fix/Correct UnavailableGuild object * Fix testcase that relied on false behavior implemented by older spacebar servers * Increase limit integer size to match spacebars' possibilities * Cargo nextest on wasm, Parallelize "Check common non-default feat. cfg." * forgor installing nextest * Revert: nextest on wasm * Bump browser_version according to https://www.useragents.me/#most-common-desktop-useragents * Fix voice_simple example * Update documentation in gateway_observers example * Readd Observer trait as reexport * remove cargo lock from example * Fix #525 (pr #532) * change theme_colors from Vec<u32> to (u32, u32) * Custom ThemeColors type with sqlx::Encode and sqlx::Decode impls * impl sqlx::Type for ThemeColors * More accurate "GatewayHello::default()" * Manually implement std::default::Default for GatewayHeartbeat and GatewayHeartbeatAck * bump versions of packages to latest compatible versions * Update MSRV (#540) * Update msrv * sqlx related improvements (#542) * Bump sqlx to 0.8.0 * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Update sqlx syntax to 0.8.0, change MySql for sqlx:: Any * Modify chorus_macros::SqlxBitflagDerive to use sqlx::Any over sqlx::MySql (broken!) * Fix: `cannot infer type for type parameter `DB` declared on the trait...` * Change remaining impls of sqlx traits for MySql to sqlx::Any * Alter chorus_macros to correctly derive SqlxBitFlag for sqlx::Any * rustc/clippy>=v1.80.0: Do not warn when encountering cfg(tarpaulin_include) * Port compare_* methods to sqlx v0.8.0 * CI/CD: add cargo-doc job (#544) * CI/CD: add cargo-doc job * fix: make it rustdoc, totally not clippy * Initial support for PostgreSQL (#548) * Change sqlx::Any to sqlx::Postgres * Change sqlx::Any to sqlx::Postgres * Remove JSONified overrides when sqlx feature is enabled, where it makes sense * Add num-bigint dep * Remove generic impl for From<T> for Snowflake For some reason, this trait bound conflicts with another trait bound from the sqlx-pg-uint crate, even though I personally don't get why. * Remove num_bigint, adsd sqlx-pg-uint * swap u64 for PgU64 in some files * use v0.3.0 of sqlx-pg-uint * Lots of sqlx-postgres type changes * Lots of sqlx-postgres type changes * gwah * Change repr(i8) to repr(i16) in enums when sqlx feature is enabled, fix sqlx incompatibilities * impl sqlx::postgres::PgHasArrayType for Snowflake * Try: derive Type for FriendSourceFlags, GuildFolder * Try: Derive FromRow, Type for DefaultReaction * Try: Derive Type for CustomStatus * Try: Derive Type, FromRow for Tag * Replace conditional compiling of uNN/PgUNN with conditional compiled type alias * Fix: Conditional compiling errors and warnings * Bump: wasm-bindgen* crate versions * Bump sqlx-pg-uint * Uncomment and update decode_token() * Snowflake: PgU64 as base for sqlx (#551) * Bump sqlx-pg-uint, sqlx * Use PgU64 as base for implementations of sqlx traits for Snowflake * sqlx_bitflag_derive: Use PgU64 as translation base (#552) * sqlx_bitflag_derive: Use PgU64 as translation base * Bump version of chorus-macros * Prefer `&str` over `String` when possible (#553) Prefer &str over String where possible. * Tungstenite: Match scheme for "ws" or "wss" (#554) Match scheme for "ws" or "wss" and choose whether to connect with TLS connector for tungstenite * Add missing `impl From<Snowflake> for u64`, closes `From<Snowflake> for u64` missing #550 * Update README.md * Bump package versions * move up sending identify * Make instance GatewayOptions configurable for library consumers (#555) * Make instance GatewayOptions configurable for library consumers * Update example in README * Revert d846ce9948ebb07988428250d6a02d2ea920a451 * 0.16.0: fix lints (#558) * chore: fix doc lints * fix: use different chrono function due to deprecation * chore: format * Bump version to v0.16.0 --------- Co-authored-by: Gábor Szabó <gabor@szabgab.com> Co-authored-by: Flori <39242991+bitfl0wer@users.noreply.github.com> Co-authored-by: Quat3rnion <quat3rnion@proton.me> Co-authored-by: Quat3rnion <81202811+Quat3rnion@users.noreply.github.com> Co-authored-by: bitfl0wer <florian@pro-weber.com>
2024-08-28 20:11:52 +02:00
[Rust]: https://img.shields.io/badge/Rust-orange?style=plastic&logo=rust
[Rust-url]: https://www.rust-lang.org/
[build-shield]: https://img.shields.io/github/actions/workflow/status/polyphony-chat/chorus/build_and_test.yml?style=flat
[build-url]: https://github.com/polyphony-chat/chorus/blob/main/.github/workflows/build_and_test.yml
[clippy-shield]: https://img.shields.io/github/actions/workflow/status/polyphony-chat/chorus/clippy.yml?style=flat
[clippy-url]: https://github.com/polyphony-chat/chorus/blob/main/.github/workflows/clippy.yml
[contributors-shield]: https://img.shields.io/github/contributors/polyphony-chat/chorus.svg?style=flat
[contributors-url]: https://github.com/polyphony-chat/chorus/graphs/contributors
[coverage-shield]: https://coveralls.io/repos/github/polyphony-chat/chorus/badge.svg?branch=main
[coverage-url]: https://coveralls.io/github/polyphony-chat/chorus?branch=main
[forks-shield]: https://img.shields.io/github/forks/polyphony-chat/chorus.svg?style=flat
[forks-url]: https://github.com/polyphony-chat/chorus/network/members
[stars-shield]: https://img.shields.io/github/stars/polyphony-chat/chorus.svg?style=flat
[stars-url]: https://github.com/polyphony-chat/chorus/stargazers
[issues-shield]: https://img.shields.io/github/issues/polyphony-chat/chorus.svg?style=flat
[issues-url]: https://github.com/polyphony-chat/chorus/issues
[license-shield]: https://img.shields.io/github/license/polyphony-chat/chorus.svg?style=f;at
[license-url]: https://github.com/polyphony-chat/chorus/blob/master/LICENSE
[Discord]: https://dcbadge.vercel.app/api/server/m3FpcapGDD?style=flat
[Discord-invite]: https://discord.com/invite/m3FpcapGDD