pub fn encode_readdir_page(
entries: &[ReaddirEntry],
offset: u64,
count: u32,
) -> Vec<u8> ⓘExpand description
Encode a directory listing as a page of standard 9P2000.L Rreaddir dirent records with cookie-based paging.
Each record is qid[13] · offset[8] · type[1] · name[s] — the exact shape
parse_readdir_entries (and any standard client such as progrium/p9)
decodes. entries is the full listing in a stable order; the record’s
offset is a resumption cookie equal to the entry’s 1-based index.
Paging contract (as required by 9P2000.L, distinct from a byte-offset read):
offsetis a dirent cookie — only entries whose cookie is> offsetare emitted (so a client resumes by passing back the last cookie it saw).countis a byte budget — records are packed whole (never split) until the next record would exceed it. A single record larger thancountis still emitted alone so the client can always make progress.
The dirent type byte is the entry’s qid type (QTDIR=0x80 / QTFILE=0x00);
progrium/p9 reads it as a QIDType, and Wanix’s p9kit re-walks each name
anyway, so this is the interoperable choice.