Skip to main content

PlayerInfo

Struct PlayerInfo 

Source
#[repr(C)]
pub struct PlayerInfo { pub header: Header, pub slot: u32, pub entity: Entity, pub key: PlayerKey, pub permissions: u8, pub name_len: u8, pub name: [u8; 64], }
Expand description

A connected player, from HostApi::player or HostApi::players.

Unlike other structs with a Header, its layout is frozen and it never grows: ActionCall and RenameCall carry it before fields of their own, and HostApi::players writes an array of it with no entry size. Player data a later minor adds goes into a new struct. The caller still starts each one it passes with Header::of.

§Examples

use enshwick::abi::{Header, PlayerInfo};

let mut name = [0u8; 64];
name[..3].copy_from_slice(b"Ann");
let player = PlayerInfo {
    header: Header::of::<PlayerInfo>(),
    slot: 0,
    entity: enshwick::Entity(2),
    key: enshwick::PlayerKey::new(7),
    permissions: PlayerInfo::CAN_ACCESS_INVENTORIES,
    name_len: 3,
    name,
};
assert_eq!(&player.name[..usize::from(player.name_len)], b"Ann");

Fields§

§header: Header

Size and version of this struct.

§slot: u32

The server’s player slot.

§entity: Entity

The player character’s entity.

§key: PlayerKey

The same number for the same account in every session.

§permissions: u8

The server’s permission bits for the player: 1 kick and ban, 2 open inventories, 4 edit the base, 8 edit the world, 16 extend the base, 32 receive experience.

§name_len: u8

Bytes of name in use.

§name: [u8; 64]

The name the client sent, UTF-8 as sent, cut at 64 bytes.

Implementations§

Source§

impl PlayerInfo

Source

pub const CAN_KICK_BAN: u8 = 1

May kick and ban; the server’s administrators.

Source

pub const CAN_ACCESS_INVENTORIES: u8

May open chests and other inventories.

Source

pub const CAN_EDIT_BASE: u8

May build in bases.

Source

pub const CAN_EDIT_WORLD: u8

May change the world outside bases.

Source

pub const CAN_EXTEND_BASE: u8

May extend bases.

Source

pub const CAN_RECEIVE_EXP: u8

Receives experience.

Trait Implementations§

Source§

impl Clone for PlayerInfo

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for PlayerInfo

Source§

impl Debug for PlayerInfo

Source§

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

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

impl Headed for PlayerInfo

Source§

impl Zeroable for PlayerInfo

Source§

fn zeroed() -> Self

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

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

Mutably borrows from an owned value. Read more
Source§

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

Source§

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

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

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

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

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

Source§

type Error = !

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

fn try_from(value: U) -> Result<T, !>

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.