I have a feeling that one of these branches will always be taken, but in order to be explicit I feel like this should always be `buf.len()`. I'm not sure that we allow short-writes?