Something went wrong. Try again.
wip/draft: git transport over iroh
Something went wrong. Try again.
1.0 kB · 39 lines
Rust
at main
12345678910111213141516171819202122232425262728293031323334353637383940//! Iroh protocol constants and stream helpers.
/// ALPN for git-remote-iroh connections.pub const GIT_IROH_ALPN: &[u8] = b"git/iroh/0";
/// Stream header sent at the start of a git stream./// Identifies whether this is a push (receive-pack) or fetch (upload-pack).#[derive(Debug, Clone, Copy, PartialEq)]pub enum GitOp { /// Client wants to push (server runs git-receive-pack) Push, /// Client wants to fetch (server runs git-upload-pack) Fetch,}
impl GitOp { pub fn to_byte(self) -> u8 { match self { GitOp::Push => 1, GitOp::Fetch => 2, } }
pub fn from_byte(b: u8) -> Option<Self> { match b { 1 => Some(GitOp::Push), 2 => Some(GitOp::Fetch), _ => None, } }
/// The git command to run on the server side. pub fn server_command(self) -> &'static str { match self { GitOp::Push => "git-receive-pack", GitOp::Fetch => "git-upload-pack", } }}