Something went wrong. Try again.
This repository has no description
Something went wrong. Try again.
2.0 kB · 61 lines
Rust
at main
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162//! vocabulary shared by the projection modules, lifted from knot-xrpc/src/wire.rs.//! single definition point: `out`, `patchtext`, `bounded`, and `read_model` all render//! the same upstream shapes.
use knot_git::EntryKind;
// Origin: knot-xrpc/src/wire.rs: entry_mode_decimalpub fn entry_mode_decimal(kind: EntryKind) -> u32 { match kind { EntryKind::Tree => 0o040000, EntryKind::Blob => 0o100644, EntryKind::BlobExecutable => 0o100755, EntryKind::Link => 0o120000, EntryKind::Commit => 0o160000, }}
// Origin: knot-xrpc/src/wire.rs: entry_mode_octalpub fn entry_mode_octal(kind: EntryKind) -> String { format!("{:06o}", entry_mode_decimal(kind))}
// Origin: knot-xrpc/src/wire.rs: fold_subjectpub fn fold_subject(message: &str) -> String { message .split("\n\n") .next() .unwrap_or_default() .lines() .map(str::trim_end) .filter(|line| !line.is_empty()) .collect::<Vec<_>>() .join(" ")}
// Origin: knot-xrpc/src/wire.rs: message_bodypub fn message_body(message: &str) -> String { message .split_once("\n\n") .map(|(_, body)| body.trim_matches('\n')) .unwrap_or_default() .to_string()}
// Origin: knot-xrpc/src/wire.rs: rfc2822pub fn rfc2822(seconds: i64, offset_seconds: i32) -> String { zoned(seconds, offset_seconds).to_rfc2822()}
// Origin: knot-xrpc/src/wire.rs: rfc3339pub fn rfc3339(seconds: i64, offset_seconds: i32) -> String { zoned(seconds, offset_seconds).to_rfc3339_opts(chrono::SecondsFormat::Secs, true)}
fn zoned(seconds: i64, offset_seconds: i32) -> chrono::DateTime<chrono::FixedOffset> { let offset = chrono::FixedOffset::east_opt(offset_seconds) .unwrap_or_else(|| chrono::FixedOffset::east_opt(0).expect("zero offset is valid")); chrono::DateTime::from_timestamp(seconds, 0) .unwrap_or_default() .with_timezone(&offset)}