aKode fase 5: rinomina interna (crate akode-*, akode-rs/, akode-cli/, binario akode, AKODE_*, ~/.akode, snapshot)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
22
akode-rs/core/src/utils/json.rs
Normal file
22
akode-rs/core/src/utils/json.rs
Normal file
@@ -0,0 +1,22 @@
|
||||
#[derive(Default)]
|
||||
struct JsonByteCounter(usize);
|
||||
|
||||
impl std::io::Write for JsonByteCounter {
|
||||
fn write(&mut self, bytes: &[u8]) -> std::io::Result<usize> {
|
||||
self.0 = self.0.saturating_add(bytes.len());
|
||||
Ok(bytes.len())
|
||||
}
|
||||
|
||||
fn flush(&mut self) -> std::io::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Counts serialized JSON bytes without retaining the serialized output.
|
||||
pub(crate) fn serialized_json_bytes<T: serde::Serialize + ?Sized>(
|
||||
value: &T,
|
||||
) -> serde_json::Result<usize> {
|
||||
let mut counter = JsonByteCounter::default();
|
||||
serde_json::to_writer(&mut counter, value)?;
|
||||
Ok(counter.0)
|
||||
}
|
||||
2
akode-rs/core/src/utils/mod.rs
Normal file
2
akode-rs/core/src/utils/mod.rs
Normal file
@@ -0,0 +1,2 @@
|
||||
pub(crate) mod json;
|
||||
pub mod path_utils;
|
||||
1
akode-rs/core/src/utils/path_utils.rs
Normal file
1
akode-rs/core/src/utils/path_utils.rs
Normal file
@@ -0,0 +1 @@
|
||||
pub use akode_utils_path::*;
|
||||
Reference in New Issue
Block a user