#![allow(dead_code)]
#[macro_use]
extern crate lazy_static;
pub mod constants;
pub mod coord;
pub mod cube;
pub mod cubie;
pub mod error;
pub mod facelet;
pub mod gui;
pub mod moves;
pub mod notation;
pub mod pruning;
pub mod scramble;
pub mod solver;
pub mod symmetries;
pub use crate::error::Result;
pub use crate::moves::Move;
pub use crate::solver::{solve, solve_facelet, solve_scramble};
use crate::error::Error;
use bincode::{
config::{self, Configuration},
decode_from_slice, encode_to_vec,
error::DecodeError,
Decode, Encode,
};
use std::{fs, path::Path};
const CONFIG: Configuration = config::standard();
pub(crate) fn write_table<P, T: Encode>(path: P, table: &T) -> std::result::Result<(), Error>
where
P: AsRef<Path>,
{
let encoded = encode_to_vec(table, CONFIG)?;
fs::write(path, encoded)?;
Ok(())
}
pub(crate) fn decode_table<T: Decode<()>>(bytes: &[u8]) -> std::result::Result<T, Error> {
let (decoded, written) = decode_from_slice(bytes, CONFIG)?;
let additional = bytes.len() - written;
if additional != 0 {
return Err(DecodeError::UnexpectedEnd { additional }.into());
}
Ok(decoded)
}