documentation
move as_bytes into utility function