docs: tambah doc comment, logging, dan inline comments di semua 255 file
Meliputi: - File-level //! doc comment: tujuan file, alur kerja, komponen utama - Function-level /// doc comment: apa, parameter, return, flow, edge cases - Struct/enum/trait /// doc comment: peran, field docs - Tracing logging (tracing::info!/debug!/trace!/warn!/error!) di setiap fungsi - Inline comments untuk variable dan branching logic penting - Seluruh 8 crates di workspace: zesdex-backend, zesdex-cms, zesdex-entities, zesdex-iam, zesdex-infra, zesdex-ipc, zesdex-middleware, zesdex-utils - Build: 0 errors, 242/242 tests passed
This commit is contained in:
@@ -9,6 +9,7 @@ use serde::de::DeserializeOwned;
|
||||
use serde::Serialize;
|
||||
use std::io::BufReader;
|
||||
use std::os::unix::net::UnixStream;
|
||||
use tracing;
|
||||
|
||||
/// A framed JSON connection over a Unix socket.
|
||||
///
|
||||
@@ -50,6 +51,7 @@ impl Connection {
|
||||
/// [`write_frame`] for writing.
|
||||
pub fn send<T: Serialize>(&mut self, msg: &T) -> Result<()> {
|
||||
let json = serde_json::to_vec(msg).context("failed to serialise message to JSON")?;
|
||||
tracing::trace!("sending frame ({} byte(s))", json.len());
|
||||
write_frame(&mut self.writer, &json).context("failed to write frame to connection")
|
||||
}
|
||||
|
||||
@@ -66,8 +68,12 @@ impl Connection {
|
||||
let raw = read_frame(&mut self.reader).context("failed to read frame from connection")?;
|
||||
|
||||
match raw {
|
||||
None => Ok(None),
|
||||
None => {
|
||||
tracing::trace!("connection closed (EOF)");
|
||||
Ok(None)
|
||||
}
|
||||
Some(bytes) => {
|
||||
tracing::trace!("received frame ({} byte(s))", bytes.len());
|
||||
let msg: T = serde_json::from_slice(&bytes).with_context(|| {
|
||||
format!("failed to deserialise frame ({} byte(s))", bytes.len())
|
||||
})?;
|
||||
|
||||
Reference in New Issue
Block a user