pub struct User {
pub user: Option<UserInfo>,
pub client_token: String,
pub available_profiles: Vec<UserProfile>,
pub selected_profile: UserProfile,
/* private fields */
}Expand description
Structure representing a Mojang user.
Fields§
§user: Option<UserInfo>User object.
client_token: StringClient identifier.
available_profiles: Vec<UserProfile>ADoesn’t do anything for now.
selected_profile: UserProfileCurrently selected user profile.
Implementations§
Source§impl User
impl User
Sourcepub fn authenticate(username: String, password: String) -> Self
pub fn authenticate(username: String, password: String) -> Self
Authenticate with the Mojang authentication servers. Returns a new User.
Examples found in repository?
examples/login.rs (lines 12-15)
11fn main() {
12 let user = user::User::authenticate(
13 env::var("MOJANG_USER").unwrap(),
14 env::var("MOJANG_USER_PWD").unwrap(),
15 );
16
17 let mut server = server::Server::new("127.0.0.1", None, None).unwrap();
18
19 server.connect_player(user).unwrap();
20
21 loop {
22 match server.read_event() {
23 Ok(e) => println!("{:?}", e),
24 Err(e) => match e {
25 errors::ConnectionError::LockError(_) => {
26 thread::sleep(time::Duration::from_millis(50));
27 continue;
28 }
29 errors::ConnectionError::Error(e) => panic!("Error while reading event: {:?}", e),
30 },
31 }
32 }
33}Sourcepub fn join_server(&self, server_id: &str, shared_key: &[u8], public_key: &[u8])
pub fn join_server(&self, server_id: &str, shared_key: &[u8], public_key: &[u8])
Send a server join request to Mojang.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for User
impl<'de> Deserialize<'de> for User
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for User
impl RefUnwindSafe for User
impl Send for User
impl Sync for User
impl Unpin for User
impl UnwindSafe for User
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more