pub fn read_path(
path: &Path,
limits: &Limits,
meter: &Arc<Meter>,
) -> Result<Bytes, Error>Expand description
Reads path whole for Source::Path. A file whose length is above
limits.max_input_bytes is refused before anything is read
(LimitKind::InputBytes). The buffer is allocated once at the stat’d
length, charged to meter first, and filled; the end of the file is then
checked with a read into a fixed stack buffer, so a file that ends where
its length says costs exactly its buffer (heap_cost(len) and the owner
record, crate::budget::OWNER_COST), never a growth past it. Only a
file that outlasts its stat’d length (one that grows while it is read, a
pipe, a device) grows the buffer, charged as it grows, and the read stops
at the bound. The returned bytes carry the charge.