pub struct MazeSolutionWasm {
pub solution: MazeSolution,
}Expand description
Web assembly representation of a maze solution
Fields§
§solution: MazeSolutionImplementations§
Source§impl MazeSolutionWasm
impl MazeSolutionWasm
Sourcepub fn get_path_points(&self) -> Array
pub fn get_path_points(&self) -> Array
Returns the array of points (if any) associated with the maze solution
§Returns
This function will return an array of Javascript objects defining each point in the solution. Each solution point object has the folllowing properties:
row- zero-based row index for the solution pointcol- zero-based column index for the solution point
§Examples
Initialize a maze from a JSON string, then attempt to solve it and, if successful, print the maze solution path’s points
// Javascript <script> content:
import init, { MazeWasm } from 'maze_wasm.js';
async function run() {
await init();
try {
let maze = new MazeWasm();
maze.from_json(`{
\"id\":\"maze_id\",
\"name\":\"test\",
\"definition\": {
\"grid\":[
[\"S\", \"W\", \" \", \" \", \"W\"],
[\" \", \"W\", \" \", \"W\", \" \"],
[\" \", \" \", \" \", \"W\", \"F\"],
[\"W\", \" \", \"W\", \" \", \" \"],
[\" \", \" \", \" \", \"W\", \" \"],
[\"W\", \"W\", \" \", \" \", \" \"],
[\"W\", \"W\", \" \", \"W\", \" \"]
]
}}`);
let solution = maze.solve();
let solutionPoints = solution.get_path_points();
console.log("Successfully solved maze. Solution points are: ", solutionPoints);
} catch (e) {
console.error("Operation failed: ", e);
}
}
run();Trait Implementations§
Source§impl From<MazeSolutionWasm> for JsValue
impl From<MazeSolutionWasm> for JsValue
Source§fn from(value: MazeSolutionWasm) -> Self
fn from(value: MazeSolutionWasm) -> Self
Converts to this type from the input type.
Source§impl FromWasmAbi for MazeSolutionWasm
impl FromWasmAbi for MazeSolutionWasm
Source§impl IntoWasmAbi for MazeSolutionWasm
impl IntoWasmAbi for MazeSolutionWasm
Source§impl OptionFromWasmAbi for MazeSolutionWasm
impl OptionFromWasmAbi for MazeSolutionWasm
Source§impl OptionIntoWasmAbi for MazeSolutionWasm
impl OptionIntoWasmAbi for MazeSolutionWasm
Source§impl RefFromWasmAbi for MazeSolutionWasm
impl RefFromWasmAbi for MazeSolutionWasm
Source§type Anchor = RcRef<MazeSolutionWasm>
type Anchor = RcRef<MazeSolutionWasm>
The type that holds the reference to
Self for the duration of the
invocation of the function that has an &Self parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous.Source§impl RefMutFromWasmAbi for MazeSolutionWasm
impl RefMutFromWasmAbi for MazeSolutionWasm
Source§impl TryFromJsValue for MazeSolutionWasm
impl TryFromJsValue for MazeSolutionWasm
Source§impl VectorFromWasmAbi for MazeSolutionWasm
impl VectorFromWasmAbi for MazeSolutionWasm
type Abi = <Box<[JsValue]> as FromWasmAbi>::Abi
unsafe fn vector_from_abi(js: Self::Abi) -> Box<[MazeSolutionWasm]>
Source§impl VectorIntoJsValue for MazeSolutionWasm
impl VectorIntoJsValue for MazeSolutionWasm
fn vector_into_jsvalue(vector: Box<[MazeSolutionWasm]>) -> JsValue
Source§impl VectorIntoWasmAbi for MazeSolutionWasm
impl VectorIntoWasmAbi for MazeSolutionWasm
type Abi = <Box<[JsValue]> as IntoWasmAbi>::Abi
fn vector_into_abi(vector: Box<[MazeSolutionWasm]>) -> Self::Abi
Source§impl WasmDescribeVector for MazeSolutionWasm
impl WasmDescribeVector for MazeSolutionWasm
Auto Trait Implementations§
impl Freeze for MazeSolutionWasm
impl RefUnwindSafe for MazeSolutionWasm
impl Send for MazeSolutionWasm
impl Sync for MazeSolutionWasm
impl Unpin for MazeSolutionWasm
impl UnwindSafe for MazeSolutionWasm
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
Source§type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as
IntoWasmAbi::AbiSource§fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as
IntoWasmAbi::into_abi, except that it may throw and never
return in the case of Err.