[−][src]Struct screeps::LocalRoomPosition
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: LocalRoomName
x: u32
y: u32
Methods
impl LocalRoomPosition
[src]
pub fn remote(&self) -> RoomPosition
[src]
Trait Implementations
impl HasPosition for LocalRoomPosition
[src]
fn pos(&self) -> RoomPosition
[src]
impl PartialEq<LocalRoomPosition> for LocalRoomPosition
[src]
fn eq(&self, other: &LocalRoomPosition) -> bool
[src]
fn ne(&self, other: &LocalRoomPosition) -> bool
[src]
impl Clone for LocalRoomPosition
[src]
fn clone(&self) -> 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<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
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.
fn try_from(v: Value) -> Result<LocalRoomPosition, Self::Error>
[src]
impl TryFrom<LocalRoomPosition> for Value
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: LocalRoomPosition) -> Result<Self, Self::Error>
impl<'_a> TryFrom<&'_a LocalRoomPosition> for Value
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: &'_a LocalRoomPosition) -> Result<Self, Self::Error>
impl<'_a> TryFrom<&'_a mut LocalRoomPosition> for Value
type Error = ConversionError
The type returned in the event of a conversion error.
fn try_from(value: &'_a mut LocalRoomPosition) -> Result<Self, Self::Error>
impl JsSerialize for LocalRoomPosition
fn _into_js<'x>(&'x self) -> SerializedValue<'x>
impl JsSerializeOwned for LocalRoomPosition
fn into_js_owned<'_a>(value: &'_a mut Option<Self>) -> SerializedValue<'_a>
impl<'_r> JsSerializeOwned for &'_r LocalRoomPosition
fn into_js_owned<'_a>(value: &'_a mut Option<Self>) -> SerializedValue<'_a>
impl Serialize for LocalRoomPosition
[src]
impl<'de> Deserialize<'de> for LocalRoomPosition
[src]
fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where
D: Deserializer<'de>,
[src]
D: Deserializer<'de>,
Auto Trait Implementations
impl Sync for LocalRoomPosition
impl Unpin for LocalRoomPosition
impl Send for LocalRoomPosition
impl UnwindSafe for LocalRoomPosition
impl RefUnwindSafe for LocalRoomPosition
Blanket Implementations
impl<T> HasPosition for T where
T: RoomObjectProperties,
[src]
T: RoomObjectProperties,
fn pos(&Self) -> RoomPosition
[src]
impl<T, U> IntoExpectedType<U> for T where
U: FromExpectedType<T>,
[src]
U: FromExpectedType<T>,
fn into_expected_type(Self) -> Result<U, ConversionError>
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T> From<T> for T
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<T> DeserializeOwned for T where
T: Deserialize<'de>,
[src]
T: Deserialize<'de>,