cleanup
This commit is contained in:
parent
cce932400a
commit
592a67a304
@ -115,7 +115,7 @@ impl FunctionManager {
|
|||||||
);
|
);
|
||||||
|
|
||||||
// Only keep valid chars
|
// Only keep valid chars
|
||||||
new_string.retain(|c| crate::misc::is_valid_char(&c));
|
new_string.retain(|c| crate::misc::is_valid_char(c));
|
||||||
|
|
||||||
// If not fully open, return here as buttons cannot yet be displayed, therefore the user is inable to mark it for deletion
|
// If not fully open, return here as buttons cannot yet be displayed, therefore the user is inable to mark it for deletion
|
||||||
let animate_bool = ui.ctx().animate_bool(te_id, re.has_focus());
|
let animate_bool = ui.ctx().animate_bool(te_id, re.has_focus());
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#![feature(const_slice_index)]
|
#![feature(const_slice_index)]
|
||||||
#![feature(slice_split_at_unchecked)]
|
#![feature(slice_split_at_unchecked)]
|
||||||
#![feature(inline_const)]
|
#![feature(inline_const)]
|
||||||
|
#![feature(const_for)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate static_assertions;
|
extern crate static_assertions;
|
||||||
@ -26,13 +27,14 @@ pub use crate::{
|
|||||||
function_entry::{FunctionEntry, Riemann},
|
function_entry::{FunctionEntry, Riemann},
|
||||||
math_app::AppSettings,
|
math_app::AppSettings,
|
||||||
misc::{
|
misc::{
|
||||||
// decimal_round,
|
|
||||||
hashed_storage_create,
|
|
||||||
hashed_storage_read,
|
hashed_storage_read,
|
||||||
newtons_method,
|
newtons_method,
|
||||||
option_vec_printer,
|
option_vec_printer,
|
||||||
step_helper,
|
step_helper,
|
||||||
EguiHelper,
|
EguiHelper,
|
||||||
|
// decimal_round,
|
||||||
|
// hashed_storage_create,
|
||||||
|
HashBytesHelper,
|
||||||
},
|
},
|
||||||
unicode_helper::{to_chars_array, to_unicode_hash},
|
unicode_helper::{to_chars_array, to_unicode_hash},
|
||||||
};
|
};
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
#![feature(const_slice_index)]
|
#![feature(const_slice_index)]
|
||||||
#![feature(slice_split_at_unchecked)]
|
#![feature(slice_split_at_unchecked)]
|
||||||
#![feature(inline_const)]
|
#![feature(inline_const)]
|
||||||
|
#![feature(const_for)]
|
||||||
|
|
||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate static_assertions;
|
extern crate static_assertions;
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
use crate::{
|
use crate::{
|
||||||
consts::*, function_entry::Riemann, function_manager::FunctionManager, misc::option_vec_printer,
|
consts::*,
|
||||||
|
function_entry::Riemann,
|
||||||
|
function_manager::FunctionManager,
|
||||||
|
misc::{option_vec_printer, HashBytesHelper},
|
||||||
};
|
};
|
||||||
use eframe::App;
|
use eframe::App;
|
||||||
use egui::{
|
use egui::{
|
||||||
@ -214,7 +217,7 @@ impl MathApp {
|
|||||||
std::mem::transmute::<&str, crate::misc::HashBytes>(build::SHORT_COMMIT)
|
std::mem::transmute::<&str, crate::misc::HashBytes>(build::SHORT_COMMIT)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let saved_data = &crate::misc::hashed_storage_create(&commit, data);
|
let saved_data = commit.hashed_storage_create(data);
|
||||||
tracing::info!("Bytes: {}", saved_data.len());
|
tracing::info!("Bytes: {}", saved_data.len());
|
||||||
get_localstorage()
|
get_localstorage()
|
||||||
.set_item(DATA_NAME, saved_data)
|
.set_item(DATA_NAME, saved_data)
|
||||||
|
|||||||
13
src/misc.rs
13
src/misc.rs
@ -172,9 +172,14 @@ pub const HASH_LENGTH: usize = 8;
|
|||||||
/// Represents bytes used to represent hash info
|
/// Represents bytes used to represent hash info
|
||||||
pub type HashBytes = [u8; HASH_LENGTH];
|
pub type HashBytes = [u8; HASH_LENGTH];
|
||||||
|
|
||||||
#[allow(dead_code)]
|
pub trait HashBytesHelper {
|
||||||
pub fn hashed_storage_create(hash: &HashBytes, data: &[u8]) -> String {
|
fn hashed_storage_create(&self, data: &[u8]) -> String;
|
||||||
unsafe { std::mem::transmute::<Vec<u8>, String>([hash, data].concat()) }
|
}
|
||||||
|
|
||||||
|
impl HashBytesHelper for HashBytes {
|
||||||
|
fn hashed_storage_create(&self, data: &[u8]) -> String {
|
||||||
|
unsafe { std::mem::transmute::<Vec<u8>, String>([self, data].concat()) }
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
@ -206,4 +211,4 @@ pub fn random_u64() -> Result<u64, getrandom::Error> {
|
|||||||
|
|
||||||
include!(concat!(env!("OUT_DIR"), "/valid_chars.rs"));
|
include!(concat!(env!("OUT_DIR"), "/valid_chars.rs"));
|
||||||
|
|
||||||
pub fn is_valid_char(c: &char) -> bool { c.is_alphanumeric() | VALID_EXTRA_CHARS.contains(c) }
|
pub fn is_valid_char(c: char) -> bool { c.is_alphanumeric() | VALID_EXTRA_CHARS.contains(&c) }
|
||||||
|
|||||||
@ -62,20 +62,18 @@ fn option_vec_printer() {
|
|||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn hashed_storage() {
|
fn hashed_storage() {
|
||||||
use ytbn_graphing_software::{hashed_storage_create, hashed_storage_read};
|
use ytbn_graphing_software::{hashed_storage_read, HashBytesHelper};
|
||||||
|
|
||||||
let commit = "abcdefeg".chars().map(|c| c as u8).collect::<Vec<u8>>();
|
let commit = "abcdefeg".chars().map(|c| c as u8).collect::<Vec<u8>>();
|
||||||
let data = "really cool data"
|
let data = "really cool data"
|
||||||
.chars()
|
.chars()
|
||||||
.map(|c| c as u8)
|
.map(|c| c as u8)
|
||||||
.collect::<Vec<u8>>();
|
.collect::<Vec<u8>>();
|
||||||
let storage = hashed_storage_create(
|
let storage_tmp: [u8; 8] = commit
|
||||||
commit
|
.as_slice()
|
||||||
.as_slice()
|
.try_into()
|
||||||
.try_into()
|
.expect("cannot turn into [u8; 8]");
|
||||||
.expect("cannot turn into [u8; 8]"),
|
let storage = storage_tmp.hashed_storage_create(data.as_slice());
|
||||||
data.as_slice(),
|
|
||||||
);
|
|
||||||
|
|
||||||
let read = hashed_storage_read(&storage);
|
let read = hashed_storage_read(&storage);
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user