[][src]Struct screeps::LocalRoomPosition

pub struct LocalRoomPosition {
    pub room_name: LocalRoomName,
    pub x: u32,
    pub y: u32,
}

This is a room position located in Rust memory.

It's "local" in the sense that while RoomPosition always references a room position allocated by and managed by the JavaScript VM, this is a self-contained plain-data struct in Rust memory.

Using LocalRoomPosition

A LocalRoomPosition can be retrieved at any point by using RoomPosition::local. It can then be copied around freely, and have its values modified.

&LocalRoomPosition can be passed into any game method taking an object, and will be automatically uploaded to JavaScript as a RoomPosition.

If you need to manually create a RoomPosition from a LocalRoomPosition, use LocalRoomPosition::remote.

Serialization

LocalRoomPosition implements both serde::Serialize and serde::Deserialize.

When serializing, it will use the obvious format of {roomName: String, x: u32, y: u32} in "human readable" formats like JSON, and a less obvious format {room_x: u32, room_y: u32, x: u32, y: u32} in "non-human readable" formats like bincode.

You can also pass LocalRoomPosition into JavaScript using the js!{} macro provided by stdweb, or helper methods using the same code like MemoryReference::set. It will be serialized the same as in JSON, as an object with roomName, x and y properties.

Note: serializing using js!{} or MemoryReference::set will not create a RoomPosition, only something with the same properties. Use .remote() if you need a RoomPosition.

Fields

room_name: LocalRoomNamex: u32y: u32

Methods

impl LocalRoomPosition[src]

pub fn remote(&self) -> RoomPosition[src]

Trait Implementations

impl HasPosition for LocalRoomPosition[src]

impl PartialEq<LocalRoomPosition> for LocalRoomPosition[src]

impl Clone for LocalRoomPosition[src]

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Copy for LocalRoomPosition[src]

impl Eq for LocalRoomPosition[src]

impl Hash for LocalRoomPosition[src]

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given [Hasher]. Read more

impl Debug for LocalRoomPosition[src]

impl Display for LocalRoomPosition[src]

fn fmt(&self, f: &mut Formatter) -> Result[src]

Formats this into a nice looking string mimicking RoomPosition's toString.

impl TryFrom<Value> for LocalRoomPosition[src]

type Error = <Value as TryInto<String>>::Error

The type returned in the event of a conversion error.

impl TryFrom<LocalRoomPosition> for Value

type Error = ConversionError

The type returned in the event of a conversion error.

impl<'_a> TryFrom<&'_a LocalRoomPosition> for Value

type Error = ConversionError

The type returned in the event of a conversion error.

impl<'_a> TryFrom<&'_a mut LocalRoomPosition> for Value

type Error = ConversionError

The type returned in the event of a conversion error.

impl JsSerialize for LocalRoomPosition

impl JsSerializeOwned for LocalRoomPosition

impl<'_r> JsSerializeOwned for &'_r LocalRoomPosition

impl Serialize for LocalRoomPosition[src]

impl<'de> Deserialize<'de> for LocalRoomPosition[src]

Auto Trait Implementations

Blanket Implementations

impl<T> HasPosition for T where
    T: RoomObjectProperties
[src]

impl<T, U> IntoExpectedType<U> for T where
    U: FromExpectedType<T>, 
[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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