pub fn memory_max_unsafe() -> Result<Option<u64>, ReadParseError>Expand description
Reads and parses the memory max file using unsafe code.
§Safety
This function is unsafe because it uses std::str::from_utf8_unchecked, which can lead to undefined behavior if the content is not valid ASCII. However the Kernel doc states that attributes should be ASCII text files.
If the file content exceeds the buffer size (1024 bytes), only part of the file will be read, potentially causing incorrect parsing.
§Errors
Returns an error if the memory max file could not be read.
§Example
match memory_max_unsafe() {
Ok(Some(v)) => println!("Max memory: {v}"),
Ok(None) => println!("No max memory constraint"),
Err(e) => println!("Failed to read and parse memory files: {e}"),
}