pub struct FileHandler { /* private fields */ }
Expand description
A handler for retrieving values from a file.
This struct is responsible for handling requests by checking for values within a specified file.
§Examples
use cor_args::{FileHandler, Handler};
// Create a new FileHandler specifying a path to a file.
let handler = FileHandler::new("/path/to/file");
// Add a fallback handler
//let handler = handler.next(some_other_handler.into());
// Handle a configuration request returning contents of `/path/to/file`
let value = handler.handle_request("");
Implementations§
Trait Implementations§
Source§impl Handler for FileHandler
impl Handler for FileHandler
Source§fn handle_request(&self, key: &str) -> Option<String>
fn handle_request(&self, key: &str) -> Option<String>
Retrieves content from the specified file.
This implementation attempts to read content from the file specified by file_path
.
If reading fails, and if a next handler is provided, it delegates the request
to the next handler. If there’s no next handler or if the file reading fails,
it returns None
.
§Arguments
key
- The key for which the value needs to be retrieved. (Note: Thekey
is currently not used directly, just passed on to the next handler.)
§Returns
An Option
containing the contents of the file, or None
if the key is not found.
Auto Trait Implementations§
impl Freeze for FileHandler
impl !RefUnwindSafe for FileHandler
impl !Send for FileHandler
impl !Sync for FileHandler
impl Unpin for FileHandler
impl !UnwindSafe for FileHandler
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more