feat: updates

This commit is contained in:
2025-03-29 00:04:25 +08:00
parent 6d3298549e
commit a6bff6d31c
36 changed files with 115 additions and 137 deletions

View File

@@ -4,6 +4,7 @@ use std::io::Read;
use base64::{DecodeError, Engine};
use base64::engine::general_purpose::{STANDARD, URL_SAFE_NO_PAD};
use rust_util::XResult;
use serde::Serialize;
pub fn base64_encode<T: AsRef<[u8]>>(input: T) -> String {
STANDARD.encode(input)
@@ -48,3 +49,10 @@ pub fn read_file_or_stdin(file: &str) -> XResult<Vec<u8>> {
Ok(opt_result!(fs::read(file), "Read file: {} failed: {}", file))
}
}
pub fn print_pretty_json<T>(value: &T)
where
T: ?Sized + Serialize,
{
println!("{}", serde_json::to_string_pretty(value).unwrap());
}