diff --git a/pricer/src/retry.rs b/pricer/src/retry.rs new file mode 100644 index 000000000..f200ced47 --- /dev/null +++ b/pricer/src/retry.rs @@ -0,0 +1,21 @@ +use std::{thread::sleep, time::Duration}; + +pub fn retry( + function: impl Fn(usize) -> color_eyre::Result, + sleep_in_s: u64, + retries: usize, +) -> color_eyre::Result { + let mut i = 0; + + loop { + let res = function(i); + + if i == retries || res.is_ok() { + return res; + } else { + sleep(Duration::from_secs(sleep_in_s)); + } + + i += 1; + } +} diff --git a/server/src/api/explorer/mod.rs b/server/src/api/explorer/mod.rs new file mode 100644 index 000000000..e69de29bb diff --git a/server/src/api/mod.rs b/server/src/api/mod.rs index a3911725f..4f9025ec4 100644 --- a/server/src/api/mod.rs +++ b/server/src/api/mod.rs @@ -1,26 +1,11 @@ -use std::time::Instant; - -use axum::{ - extract::{Query, State}, - http::HeaderMap, - response::{IntoResponse, Response}, - routing::get, - Json, Router, -}; -use color_eyre::eyre::eyre; -use reqwest::StatusCode; -use serde::Deserialize; -use serde_json::Value; -use structs::{Format, Index}; - -use crate::{log_result, traits::HeaderMapExtended}; +use axum::{routing::get, Router}; use super::AppState; -// mod handlers; -pub mod structs; +mod explorer; +mod vecs; -pub const VECS_URL_PREFIX: &str = "/api/vecs"; +pub use vecs::VecIdToIndexToVec; pub trait ApiRoutes { fn add_api_routes(self) -> Self; @@ -28,147 +13,6 @@ pub trait ApiRoutes { impl ApiRoutes for Router { fn add_api_routes(self) -> Self { - self.route(VECS_URL_PREFIX, get(handler)) + self.route("/api/vecs", get(vecs::handler)) } } - -#[derive(Debug, Deserialize)] -pub struct DatasetParams { - pub i: String, - pub v: String, - pub from: Option, - pub to: Option, - pub format: Option, -} - -pub async fn handler(headers: HeaderMap, query: Query, State(app_state): State) -> Response { - let instant = Instant::now(); - - let path = format!( - "{VECS_URL_PREFIX}?i={}&v={}{}{}", - query.i, - query.v, - query.from.map_or("".to_string(), |from| format!("&from={from}")), - query.to.map_or("".to_string(), |to| format!("&to={to}")), - ); - - match req_to_response_res(headers, query, app_state) { - Ok(response) => { - log_result(response.status(), &path, instant); - response - } - Err(error) => { - let mut response = (StatusCode::INTERNAL_SERVER_ERROR, error.to_string()).into_response(); - log_result(response.status(), &path, instant); - response.headers_mut().insert_cors(); - response - } - } -} - -fn req_to_response_res( - headers: HeaderMap, - Query(DatasetParams { format, from, i, to, v }): Query, - AppState { vecs, .. }: AppState, -) -> color_eyre::Result { - let format = Format::try_from(format).ok(); - - let indexes = i - .to_lowercase() - .split(",") - .flat_map(|s| Index::try_from(s).ok()) - .collect::>(); - - if indexes.len() > 1 { - return Err(eyre!("Multiple indexes aren't supported")); - } else if indexes.is_empty() { - return Err(eyre!("Unknown index")); - } - - let ids = v - .to_lowercase() - .split(",") - .map(|s| (s.to_owned(), vecs.get(&s.replace("_", "-")))) - .filter(|(_, opt)| opt.is_some()) - .map(|(id, vec)| (id, vec.unwrap())) - .collect::>(); - - if ids.is_empty() { - return Ok(Json(()).into_response()); - } - - let values = ids - .iter() - .flat_map(|(_, i_to_v)| i_to_v.get(indexes.first().unwrap())) - .map(|vec| -> storable_vec::Result> { vec.collect_range_values(from, to) }) - .collect::>>()?; - - if ids.is_empty() { - return Ok(Json(()).into_response()); - } - - let ids_last_i = ids.len() - 1; - - let mut response = match format { - Some(Format::CSV) | Some(Format::TSV) => { - let delimiter = if format == Some(Format::CSV) { ',' } else { '\t' }; - - let mut csv = ids - .into_iter() - .map(|(id, _)| id) - .collect::>() - .join(&delimiter.to_string()); - - csv.push('\n'); - - let values_len = values.first().unwrap().len(); - - (0..values_len).for_each(|i| { - let mut line = "".to_string(); - values.iter().enumerate().for_each(|(id_i, v)| { - line += &v.get(i).unwrap().to_string(); - if id_i == ids_last_i { - line.push('\n'); - } else { - line.push(delimiter); - } - }); - csv += &line; - }); - - csv.into_response() - } - Some(Format::JSON) | None => { - if values.len() == 1 { - let values = values.first().unwrap(); - if values.len() == 1 { - let value = values.first().unwrap(); - Json(value).into_response() - } else { - Json(values).into_response() - } - } else { - Json(values).into_response() - } - } - }; - - let headers = response.headers_mut(); - - headers.insert_cors(); - // headers.insert_last_modified(date_modified); - - match format { - Some(format) => { - headers.insert_content_disposition_attachment(); - match format { - Format::CSV => headers.insert_content_type_text_csv(), - Format::TSV => headers.insert_content_type_text_tsv(), - Format::JSON => headers.insert_content_type_application_json(), - } - } - _ => headers.insert_content_type_application_json(), - }; - - Ok(response) -} diff --git a/server/src/api/structs/mod.rs b/server/src/api/structs/mod.rs deleted file mode 100644 index 33cc08128..000000000 --- a/server/src/api/structs/mod.rs +++ /dev/null @@ -1,15 +0,0 @@ -// mod chunk_metadata; -mod format; -mod index; -// mod kind; -// mod range; -// mod route; -// mod routes; - -// pub use chunk_metadata::*; -pub use format::*; -pub use index::*; -// pub use kind::*; -// pub use range::*; -// pub use route::*; -// pub use routes::*; diff --git a/server/src/api/structs/format.rs b/server/src/api/vecs/format.rs similarity index 100% rename from server/src/api/structs/format.rs rename to server/src/api/vecs/format.rs diff --git a/server/src/api/vecs/id_to_i_to_vec.rs b/server/src/api/vecs/id_to_i_to_vec.rs new file mode 100644 index 000000000..b58be8866 --- /dev/null +++ b/server/src/api/vecs/id_to_i_to_vec.rs @@ -0,0 +1,38 @@ +use std::collections::BTreeMap; + +use derive_deref::{Deref, DerefMut}; +use storable_vec::AnyJsonStorableVec; + +use super::index::Index; + +#[derive(Default, Deref, DerefMut)] +pub struct VecIdToIndexToVec(BTreeMap); + +impl VecIdToIndexToVec { + // Not the most performant or type safe but only built once so that's okay + pub fn insert(&mut self, vec: &'static dyn AnyJsonStorableVec) { + let file_name = vec.file_name(); + let split = file_name.split("_to_").collect::>(); + if split.len() != 2 { + panic!(); + } + let str = vec.index_type_to_string().split("::").last().unwrap().to_lowercase(); + let index = Index::try_from(str.as_str()) + .inspect_err(|_| { + dbg!(str); + }) + .unwrap(); + if split[0] != index.to_string().to_lowercase() { + dbg!(split[0], index.to_string()); + panic!(); + } + let key = split[1].to_string().replace("_", "-"); + let prev = self.entry(key).or_default().insert(index, vec); + if prev.is_some() { + panic!() + } + } +} + +#[derive(Default, Deref, DerefMut)] +pub struct IndexToVec(BTreeMap); diff --git a/server/src/api/structs/index.rs b/server/src/api/vecs/index.rs similarity index 100% rename from server/src/api/structs/index.rs rename to server/src/api/vecs/index.rs diff --git a/server/src/api/vecs/mod.rs b/server/src/api/vecs/mod.rs new file mode 100644 index 000000000..2d8a39df7 --- /dev/null +++ b/server/src/api/vecs/mod.rs @@ -0,0 +1,156 @@ +use std::time::Instant; + +use axum::{ + extract::{Query, State}, + http::{HeaderMap, Uri}, + response::{IntoResponse, Response}, + Json, +}; +use color_eyre::eyre::eyre; +use reqwest::StatusCode; +use serde_json::Value; + +use crate::{log_result, traits::HeaderMapExtended}; + +use super::AppState; + +mod format; +mod id_to_i_to_vec; +mod index; +mod query; + +use format::Format; +pub use id_to_i_to_vec::*; +use index::Index; +use query::QueryS; + +pub async fn handler( + headers: HeaderMap, + uri: Uri, + query: Query, + State(app_state): State, +) -> Response { + let instant = Instant::now(); + + let path = uri.path(); + + match req_to_response_res(headers, query, app_state) { + Ok(response) => { + log_result(response.status(), path, instant); + response + } + Err(error) => { + let mut response = (StatusCode::INTERNAL_SERVER_ERROR, error.to_string()).into_response(); + log_result(response.status(), path, instant); + response.headers_mut().insert_cors(); + response + } + } +} + +fn req_to_response_res( + headers: HeaderMap, + Query(QueryS { format, from, i, to, v }): Query, + AppState { vecs, .. }: AppState, +) -> color_eyre::Result { + let format = Format::try_from(format).ok(); + + let indexes = i + .to_lowercase() + .split(",") + .flat_map(|s| Index::try_from(s).ok()) + .collect::>(); + + if indexes.len() > 1 { + return Err(eyre!("Multiple indexes aren't supported")); + } else if indexes.is_empty() { + return Err(eyre!("Unknown index")); + } + + let ids = v + .to_lowercase() + .split(",") + .map(|s| (s.to_owned(), vecs.get(&s.replace("_", "-")))) + .filter(|(_, opt)| opt.is_some()) + .map(|(id, vec)| (id, vec.unwrap())) + .collect::>(); + + if ids.is_empty() { + return Ok(Json(()).into_response()); + } + + let values = ids + .iter() + .flat_map(|(_, i_to_v)| i_to_v.get(indexes.first().unwrap())) + .map(|vec| -> storable_vec::Result> { vec.collect_range_values(from, to) }) + .collect::>>()?; + + if ids.is_empty() { + return Ok(Json(()).into_response()); + } + + let ids_last_i = ids.len() - 1; + + let mut response = match format { + Some(Format::CSV) | Some(Format::TSV) => { + let delimiter = if format == Some(Format::CSV) { ',' } else { '\t' }; + + let mut csv = ids + .into_iter() + .map(|(id, _)| id) + .collect::>() + .join(&delimiter.to_string()); + + csv.push('\n'); + + let values_len = values.first().unwrap().len(); + + (0..values_len).for_each(|i| { + let mut line = "".to_string(); + values.iter().enumerate().for_each(|(id_i, v)| { + line += &v.get(i).unwrap().to_string(); + if id_i == ids_last_i { + line.push('\n'); + } else { + line.push(delimiter); + } + }); + csv += &line; + }); + + csv.into_response() + } + Some(Format::JSON) | None => { + if values.len() == 1 { + let values = values.first().unwrap(); + if values.len() == 1 { + let value = values.first().unwrap(); + Json(value).into_response() + } else { + Json(values).into_response() + } + } else { + Json(values).into_response() + } + } + }; + + let headers = response.headers_mut(); + + headers.insert_cors(); + // headers.insert_last_modified(date_modified); + + match format { + Some(format) => { + headers.insert_content_disposition_attachment(); + match format { + Format::CSV => headers.insert_content_type_text_csv(), + Format::TSV => headers.insert_content_type_text_tsv(), + Format::JSON => headers.insert_content_type_application_json(), + } + } + _ => headers.insert_content_type_application_json(), + }; + + Ok(response) +} diff --git a/server/src/api/vecs/query.rs b/server/src/api/vecs/query.rs new file mode 100644 index 000000000..6ad5db15e --- /dev/null +++ b/server/src/api/vecs/query.rs @@ -0,0 +1,10 @@ +use serde::Deserialize; + +#[derive(Debug, Deserialize)] +pub struct QueryS { + pub i: String, + pub v: String, + pub from: Option, + pub to: Option, + pub format: Option, +} diff --git a/server/src/website/handlers/file.rs b/server/src/files/file.rs similarity index 99% rename from server/src/website/handlers/file.rs rename to server/src/files/file.rs index e94022da8..fec5e86b3 100644 --- a/server/src/website/handlers/file.rs +++ b/server/src/files/file.rs @@ -18,7 +18,7 @@ use crate::{ traits::{HeaderMapExtended, ModifiedState, ResponseExtended}, }; -use super::minify_js; +use super::minify::minify_js; const WEBSITE_DEV_PATH: &str = "../website/"; diff --git a/server/src/website/handlers/minify.rs b/server/src/files/minify.rs similarity index 100% rename from server/src/website/handlers/minify.rs rename to server/src/files/minify.rs diff --git a/server/src/website/mod.rs b/server/src/files/mod.rs similarity index 64% rename from server/src/website/mod.rs rename to server/src/files/mod.rs index 5aa3a0d09..9be3690de 100644 --- a/server/src/website/mod.rs +++ b/server/src/files/mod.rs @@ -1,16 +1,17 @@ use axum::{routing::get, Router}; -mod handlers; - -use handlers::{file_handler, index_handler}; - use super::AppState; -pub trait WebsiteRoutes { +mod file; +mod minify; + +use file::{file_handler, index_handler}; + +pub trait FilesRoutes { fn add_website_routes(self) -> Self; } -impl WebsiteRoutes for Router { +impl FilesRoutes for Router { fn add_website_routes(self) -> Self { self.route("/{*path}", get(file_handler)).route("/", get(index_handler)) } diff --git a/server/src/lib.rs b/server/src/lib.rs index dfba72c33..3f7655f6e 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -1,21 +1,20 @@ -use std::{collections::BTreeMap, time::Instant}; +use std::time::Instant; -use api::{structs::Index, ApiRoutes}; +use api::{ApiRoutes, VecIdToIndexToVec}; use axum::{routing::get, serve, Json, Router}; use color_eyre::owo_colors::OwoColorize; use computer::Computer; -use derive_deref::{Deref, DerefMut}; +use files::FilesRoutes; use indexer::Indexer; use logger::{error, info}; use reqwest::StatusCode; -use storable_vec::{AnyJsonStorableVec, STATELESS}; +use storable_vec::STATELESS; use tokio::net::TcpListener; use tower_http::compression::CompressionLayer; -use website::WebsiteRoutes; mod api; +mod files; mod traits; -mod website; #[derive(Clone)] pub struct AppState { @@ -24,40 +23,6 @@ pub struct AppState { computer: &'static Computer, } -#[derive(Default, Deref, DerefMut)] -pub struct VecIdToIndexToVec(BTreeMap); - -impl VecIdToIndexToVec { - // Not the most performant or type safe but only built once so that's okay - pub fn insert(&mut self, vec: &'static dyn AnyJsonStorableVec) { - let file_name = vec.file_name(); - let split = file_name.split("_to_").collect::>(); - if split.len() != 2 { - panic!(); - } - let str = vec.index_type_to_string().split("::").last().unwrap().to_lowercase(); - let index = Index::try_from(str.as_str()) - .inspect_err(|_| { - dbg!(str); - }) - .unwrap(); - if split[0] != index.to_string().to_lowercase() { - dbg!(split[0], index.to_string()); - panic!(); - } - let key = split[1].to_string().replace("_", "-"); - let prev = self.entry(key).or_default().insert(index, vec); - if prev.is_some() { - panic!() - } - } -} - -#[derive(Default, Deref, DerefMut)] -pub struct IndexToVec { - pub index_to_vec: BTreeMap, -} - pub async fn main(indexer: Indexer, computer: Computer) -> color_eyre::Result<()> { // pub async fn main(routes: Routes, config: Config) -> color_eyre::Result<()> { // routes.generate_dts_file(); diff --git a/server/src/website/handlers/mod.rs b/server/src/website/handlers/mod.rs deleted file mode 100644 index a0c087264..000000000 --- a/server/src/website/handlers/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -mod file; -mod minify; - -pub use file::*; -use minify::*; diff --git a/src/io/binary.rs b/src/io/binary.rs deleted file mode 100644 index 202a6bdfb..000000000 --- a/src/io/binary.rs +++ /dev/null @@ -1,139 +0,0 @@ -use std::{ - fmt::Debug, - fs::{self, File}, - io::{BufReader, BufWriter, Cursor}, - path::Path, -}; - -use bincode::{ - config, decode_from_slice, decode_from_std_read, encode_into_std_write, Decode, Encode, -}; -use zstd::decode_all; - -const ZST_EXTENSION: &str = "zst"; - -pub const BIN_EXTENSION: &str = "bin"; -pub const COMPRESSED_BIN_EXTENSION: &str = "bin.zst"; - -enum BinaryType { - Raw, - Compressed, -} - -pub struct Binary; - -impl Binary { - pub fn import(path: &Path) -> color_eyre::Result - where - T: Decode, - { - match Self::type_from_path(path) { - BinaryType::Compressed => Self::import_compressed(path), - BinaryType::Raw => Self::import_raw(path), - } - } - - fn import_raw(path: &Path) -> color_eyre::Result - where - T: Decode, - { - let config = config::standard(); - - let file = File::open(path)?; - - let mut reader = BufReader::new(file); - - let decoded = decode_from_std_read(&mut reader, config)?; - - Ok(decoded) - } - - fn import_compressed(path: &Path) -> color_eyre::Result - where - T: Decode, - { - let file = File::open(path).unwrap(); - - let reader = BufReader::new(file); - - let decompressed = decode_all(reader).unwrap(); - - let config = config::standard(); - - let decoded = decode_from_slice::(&decompressed, config)?.0; - - Ok(decoded) - } - - pub fn export(path: &Path, value: &T) -> color_eyre::Result<()> - where - T: Debug + Encode, - { - // log(&format!("Exporting: {:?}", path)); - - match Self::type_from_path(path) { - BinaryType::Compressed => Self::export_compressed(path, value), - BinaryType::Raw => Self::export_raw(path, value), - } - } - - fn export_raw(path: &Path, value: &T) -> color_eyre::Result<()> - where - T: Debug + Encode, - { - let config = config::standard(); - - let file = File::create(path).inspect_err(|_| { - dbg!(path, value); - })?; - - let mut writer = BufWriter::new(file); - - encode_into_std_write(value, &mut writer, config)?; - - Ok(()) - } - - fn export_compressed(path: &Path, value: &T) -> color_eyre::Result<()> - where - T: Debug + Encode, - { - let config = config::standard(); - - let encoded = bincode::encode_to_vec(value, config).unwrap(); - - let cursor = Cursor::new(encoded); - - let compressed = zstd::encode_all(cursor, 0).unwrap(); - - fs::write(path, compressed).unwrap(); - - Ok(()) - } - - pub fn has_correct_extension(path: &Path) -> bool { - let path = path.to_str().unwrap(); - path.ends_with(BIN_EXTENSION) || path.ends_with(COMPRESSED_BIN_EXTENSION) - } - - fn type_from_path(path: &Path) -> BinaryType { - let extension = path.extension(); - - if extension.is_none() { - panic!("Should have extension"); - } - - if !Self::has_correct_extension(path) { - dbg!(path); - panic!("Wrong extension") - } - - let extension = extension.unwrap(); - - if extension == ZST_EXTENSION { - BinaryType::Compressed - } else { - BinaryType::Raw - } - } -} diff --git a/src/io/json.rs b/src/io/json.rs deleted file mode 100644 index 6d81fe580..000000000 --- a/src/io/json.rs +++ /dev/null @@ -1,56 +0,0 @@ -use std::{ - fs::File, - io::{BufReader, BufWriter}, - path::Path, -}; - -use serde::{de::DeserializeOwned, Serialize}; - -pub struct Json; - -pub const JSON_EXTENSION: &str = "json"; -pub const HAR_EXTENSION: &str = "har"; - -impl Json { - pub fn import(path: &Path) -> color_eyre::Result - where - T: DeserializeOwned, - { - if !Self::has_correct_extension(path) { - panic!("Wrong extension"); - } - - let file = File::open(path)?; - - let reader = BufReader::new(file); - - Ok(serde_json::from_reader(reader)?) - } - - pub fn export(path: &Path, value: &T) -> color_eyre::Result<()> - where - T: Serialize, - { - if !Self::has_correct_extension(path) { - dbg!(path); - panic!("Wrong extension"); - } - - let file = File::create(path).unwrap_or_else(|_| { - dbg!(&path); - panic!("No such file or directory") - }); - - let mut writer = BufWriter::new(file); - - serde_json::to_writer_pretty(&mut writer, value)?; - - Ok(()) - } - - #[inline(always)] - pub fn has_correct_extension(path: &Path) -> bool { - let path = path.to_str().unwrap(); - path.ends_with(JSON_EXTENSION) || path.ends_with(HAR_EXTENSION) - } -} diff --git a/src/io/mod.rs b/src/io/mod.rs deleted file mode 100644 index a0540ad92..000000000 --- a/src/io/mod.rs +++ /dev/null @@ -1,7 +0,0 @@ -mod binary; -mod json; -mod serialization; - -pub use binary::*; -pub use json::*; -pub use serialization::*; diff --git a/src/io/serialization.rs b/src/io/serialization.rs deleted file mode 100644 index 9dea77275..000000000 --- a/src/io/serialization.rs +++ /dev/null @@ -1,128 +0,0 @@ -use std::{ - fmt::Debug, - fs, - path::{Path, PathBuf}, -}; - -use allocative::Allocative; -use bincode::{Decode, Encode}; -use color_eyre::eyre::eyre; -use serde::{de::DeserializeOwned, Serialize}; - -use crate::io::{Binary, Json}; - -use super::{BIN_EXTENSION, COMPRESSED_BIN_EXTENSION, HAR_EXTENSION, JSON_EXTENSION}; - -#[derive(PartialEq, PartialOrd, Ord, Eq, Debug, Clone, Copy, Default, Allocative)] -pub enum Serialization { - #[default] - Binary, - Json, -} - -impl Serialization { - pub fn is_serializable(&self, path: &Path) -> bool { - let path = path.to_str().unwrap(); - match self { - Self::Binary => { - path.ends_with(BIN_EXTENSION) || path.ends_with(COMPRESSED_BIN_EXTENSION) - } - Self::Json => path.ends_with(JSON_EXTENSION) || path.ends_with(HAR_EXTENSION), - } - } - - pub fn import(&self, path: &Path) -> color_eyre::Result - where - T: Debug + DeserializeOwned + Decode, - { - match self { - Serialization::Binary => { - if self.is_serializable(path) { - Binary::import(path) - } else { - let path = path.to_str().unwrap(); - let bin_path_str = format!("{path}.{BIN_EXTENSION}"); - let bin_path = Path::new(&bin_path_str); - - if bin_path.exists() { - return Binary::import(bin_path); - } - - let compressed_bin_path_str = format!("{path}.{COMPRESSED_BIN_EXTENSION}"); - let compressed_bin_path = Path::new(&compressed_bin_path_str); - - if compressed_bin_path.exists() { - return Binary::import(compressed_bin_path); - } - - Err(eyre!("Wrong path or no file")) - } - } - Serialization::Json => { - if self.is_serializable(path) { - Json::import(path) - } else { - let path = path.to_str().unwrap(); - let json_path_str = format!("{path}.{JSON_EXTENSION}"); - let json_path = Path::new(&json_path_str); - - if json_path.exists() { - return Json::import(json_path); - } - - Err(eyre!("Wrong path or no file")) - } - } - } - } - - pub fn export(&self, path: &Path, value: &T) -> color_eyre::Result<()> - where - T: Debug + Serialize + Encode, - { - match self { - Serialization::Binary => { - if self.is_serializable(path) { - Binary::export(path, value) - } else { - let path = path.to_str().unwrap(); - - let res = Binary::export( - Path::new(&format!("{}.{COMPRESSED_BIN_EXTENSION}", path)), - value, - ); - - if res.is_ok() { - let _ = fs::remove_file(Path::new(&format!("{}.{BIN_EXTENSION}", path))); - } - - res - } - } - Serialization::Json => { - if self.is_serializable(path) { - Json::export(path, value) - } else { - Json::export( - Path::new(&format!("{}.{JSON_EXTENSION}", path.to_str().unwrap())), - value, - ) - } - } - } - } -} - -impl TryFrom<&PathBuf> for Serialization { - type Error = (); - - fn try_from(path: &PathBuf) -> Result { - let extension = path.extension().ok_or(())?.to_str().unwrap(); - - match extension { - BIN_EXTENSION | COMPRESSED_BIN_EXTENSION => Ok(Self::Binary), - JSON_EXTENSION => Ok(Self::Json), - _ => Err(()), - } - } -} diff --git a/storable_vec/src/lib.rs b/storable_vec/src/lib.rs index 020873551..790ed1082 100644 --- a/storable_vec/src/lib.rs +++ b/storable_vec/src/lib.rs @@ -71,7 +71,7 @@ pub struct StorableVec { /// In bytes const MAX_PAGE_SIZE: usize = 4 * 4096; -const ONE_MB: usize = 1000 * 1024; +// const ONE_MB: usize = 1000 * 1024; const MAX_CACHE_SIZE: usize = usize::MAX; // const MAX_CACHE_SIZE: usize = 100 * ONE_MB;