pub struct LogLine {
pub stream: LogStreamKind,
pub timestamp: Option<DateTime<Utc>>,
pub data: Option<String>,
pub data_b64: Option<String>,
}Expand description
One framed log record on the canonical NDJSON wire.
Exactly one of data / data_b64 is
populated for records produced by from_bytes.
Fields§
§stream: LogStreamKindWhich stream this record came from.
timestamp: Option<DateTime<Utc>>Optional RFC3339 timestamp. Omitted from the wire when None.
data: Option<String>UTF-8 payload, present when the raw bytes were valid UTF-8.
data_b64: Option<String>STANDARD-base64 payload, present when the raw bytes were not valid UTF-8.
Implementations§
Source§impl LogLine
impl LogLine
Sourcepub fn from_bytes(
stream: LogStreamKind,
timestamp: Option<DateTime<Utc>>,
bytes: &[u8],
) -> Self
pub fn from_bytes( stream: LogStreamKind, timestamp: Option<DateTime<Utc>>, bytes: &[u8], ) -> Self
Build a LogLine from raw payload bytes, choosing data (valid
UTF-8) vs data_b64 (STANDARD base64) exactly like the existing
zlayer-api ndjson_line_for_chunk.
Sourcepub fn into_payload_bytes(&self) -> Vec<u8> ⓘ
pub fn into_payload_bytes(&self) -> Vec<u8> ⓘ
Recover the decoded payload bytes.
Returns the UTF-8 bytes of data when present; otherwise the
base64-decoded bytes of data_b64 (an empty Vec on decode error);
otherwise an empty Vec.
Sourcepub fn to_json_bytes(&self) -> Vec<u8> ⓘ
pub fn to_json_bytes(&self) -> Vec<u8> ⓘ
Serialize to the canonical JSON object bytes (no trailing newline).
Field presence matches the existing api shape: stream always, plus
timestamp and exactly one of data/data_b64 when populated.
Sourcepub fn to_ndjson_line(&self) -> Vec<u8> ⓘ
pub fn to_ndjson_line(&self) -> Vec<u8> ⓘ
Serialize to a single NDJSON line: to_json_bytes
followed by a trailing \n.
Sourcepub fn to_sse_frame(&self) -> Vec<u8> ⓘ
pub fn to_sse_frame(&self) -> Vec<u8> ⓘ
Serialize to a Server-Sent Events data: frame:
data: <json>\n\n. Used by the upcoming format=sse log mode.
Sourcepub fn parse_ndjson_line(line: &[u8]) -> Option<LogLine>
pub fn parse_ndjson_line(line: &[u8]) -> Option<LogLine>
Parse a single NDJSON line back into a LogLine.
A trailing \n/\r is trimmed before parsing. Returns None on a
parse failure or on a line that is empty/whitespace-only.
Sourcepub fn to_docker_frame(&self) -> Result<Vec<u8>, DockerFrameTooLarge>
pub fn to_docker_frame(&self) -> Result<Vec<u8>, DockerFrameTooLarge>
Encode this record as a Docker multiplexed-stream frame using its
stream and decoded payload bytes. See
encode_docker_frame.
§Errors
Returns DockerFrameTooLarge if the decoded payload exceeds the
Docker frame u32 length limit.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for LogLine
impl<'de> Deserialize<'de> for LogLine
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
impl Eq for LogLine
impl StructuralPartialEq for LogLine
Auto Trait Implementations§
impl Freeze for LogLine
impl RefUnwindSafe for LogLine
impl Send for LogLine
impl Sync for LogLine
impl Unpin for LogLine
impl UnsafeUnpin for LogLine
impl UnwindSafe for LogLine
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.