diff --git a/CHANGELOG.md b/CHANGELOG.md index f1c53269..f4afec1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,24 @@ Unreleased - Change return type of `RoomXY::get_range_to` and input type of `RoomXY::in_range_to` to u8 +### Additions: + +- Make `RoomName::from_packed` and `RoomName::packed_repr` public + +0.21.3 (2024-08-14) +=================== + +### Bugfixes: + +- Temporarily pin to wasm-bindgen 0.2.92 due to incompatible generated javascript + +0.21.2 (2024-08-14) +=================== + +### Bugfixes: + +- Update for new string enum implementation in wasm-bindgen 0.2.93 + ### Misc: - Move crate constant `ROOM_AREA` to extra constants module and make public diff --git a/Cargo.toml b/Cargo.toml index 3acdb927..5784c9d4 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "screeps-game-api" -version = "0.21.1" +version = "0.21.3" authors = ["David Ross "] documentation = "https://docs.rs/screeps-game-api/" edition = "2021" @@ -39,7 +39,7 @@ serde = { version = "1", features = ["derive"] } serde_json = "1" serde_repr = "0.1" serde-wasm-bindgen = "0.6" -wasm-bindgen = "0.2" +wasm-bindgen = "=0.2.92" [dev-dependencies] bincode = "1.3" diff --git a/src/constants/types.rs b/src/constants/types.rs index 934a5e7b..743ddfe2 100644 --- a/src/constants/types.rs +++ b/src/constants/types.rs @@ -674,7 +674,7 @@ impl wasm_bindgen::convert::FromWasmAbi for MarketResourceType { // try with IntershardResourceType match IntershardResourceType::from_js_value(&s) { Some(r) => Self::IntershardResource(r), - None => Self::Resource(ResourceType::__Nonexhaustive), + None => unreachable!("should have come from IntoWasmAbi"), } } } diff --git a/src/local/room_name.rs b/src/local/room_name.rs index ab2cdc6e..7e299f99 100644 --- a/src/local/room_name.rs +++ b/src/local/room_name.rs @@ -111,8 +111,9 @@ impl RoomName { x.as_ref().parse() } + /// Get the [`RoomName`] represented by a packed integer #[inline] - pub(crate) const fn from_packed(packed: u16) -> Self { + pub const fn from_packed(packed: u16) -> Self { RoomName { packed } } @@ -156,8 +157,12 @@ impl RoomName { (self.packed & 0xFF) as i32 - HALF_WORLD_SIZE } + /// Get the inner packed representation of the room name. + /// + /// This data structure matches the implementation of the upper 16 bits of + /// the js Position type. #[inline] - pub(super) const fn packed_repr(&self) -> u16 { + pub const fn packed_repr(&self) -> u16 { self.packed }