User

Struct User 

Source
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: String

Client identifier.

§available_profiles: Vec<UserProfile>

ADoesn’t do anything for now.

§selected_profile: UserProfile

Currently selected user profile.

Implementations§

Source§

impl User

Source

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

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 Debug for User

Source§

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

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

impl<'de> Deserialize<'de> for User

Source§

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

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

impl Serialize for User

Source§

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

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

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

Source§

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