///|
pub fn unix_address_text_view(raw : Bytes) -> String? {
  let mut end = 0
  while end < raw.length() && raw[end] != b'\x00' {
    if raw[end].to_int() >= 128 {
      return None
    }
    end = end + 1
  }
  let view = Bytes::from_array(raw.to_array()[0:end])
  Some(view.to_unchecked_string())
}

///|
pub fn unix_address_field(input : Bytes) -> Result[Bytes, ProxyError] {
  if input.length() > 108 {
    return Err(
      proxy_error(InvalidLength, 0, "UNIX address is longer than 108 bytes"),
    )
  }
  let buffer = @buffer.Buffer(size_hint=108)
  buffer.write_bytes(input)
  for i = input.length(); i < 108; i = i + 1 {
    buffer.write_byte(b'\x00')
  }
  Ok(buffer.to_bytes())
}