1313//!
1414//! // Login:
1515//! let session = client
16- //! .login("example@example.com".to_string() , "password".to_string() )
16+ //! .login("example@example.com", "password")
1717//! .await?;
1818//!
1919//! // Or register:
2020//! let session = client
21- //! .register("example@example.com".to_string() , "example".to_string() , "password".to_string() )
21+ //! .register("example@example.com", "example", "password")
2222//! .await?;
2323//!
2424//! // You're now logged in / registered!
5151//! You can also use the API methods in the [`api`] module
5252//! (note that you *won't* be able to store a [`Session`] that you got from these APIs inside a [`Client`]):
5353//! ```no_run
54- //! use harmony_rust_sdk::client::{Client, Session, api::foundation::login };
54+ //! use harmony_rust_sdk::client::{Client, Session, api::core::create_guild };
5555//!
5656//! let work = async {
5757//! let homeserver_url = "https://example.org".parse().unwrap();
5858//! let client = Client::new(homeserver_url, None).await?;
59- //! let session = login(&client, "example@example.org".to_string(), "password".to_string()).await?;
59+ //!
60+ //! // Auth here
61+ //!
62+ //! // Create a guild and get the guild_id from the response
63+ //! let created_guild_id = create_guild(&client, String::from("Example Guild"), None).await?.guild_id;
6064//!
6165//! // make more API calls
6266//! # harmony_rust_sdk::client::ClientResult::Ok(())
@@ -195,8 +199,8 @@ impl Client {
195199 }
196200
197201 /// Send a [`api::foundation::login`] request to the server and store the returned session.
198- pub async fn login ( & self , email : String , password : String ) -> ClientResult < ( ) > {
199- let session = api:: foundation:: login ( self , email, password) . await ?;
202+ pub async fn login ( & self , email : impl ToString , password : impl ToString ) -> ClientResult < ( ) > {
203+ let session = api:: foundation:: login ( self , email. to_string ( ) , password. to_string ( ) ) . await ?;
200204 * self . session_lock ( ) = Some ( session) ;
201205
202206 Ok ( ( ) )
@@ -205,11 +209,17 @@ impl Client {
205209 /// Send a [`api::foundation::register`] request to the server and store the returned session.
206210 pub async fn register (
207211 & self ,
208- email : String ,
209- username : String ,
210- password : String ,
212+ email : impl ToString ,
213+ username : impl ToString ,
214+ password : impl ToString ,
211215 ) -> ClientResult < ( ) > {
212- let session = api:: foundation:: register ( self , email, username, password) . await ?;
216+ let session = api:: foundation:: register (
217+ self ,
218+ email. to_string ( ) ,
219+ username. to_string ( ) ,
220+ password. to_string ( ) ,
221+ )
222+ . await ?;
213223 * self . session_lock ( ) = Some ( session) ;
214224
215225 Ok ( ( ) )
0 commit comments