Implement getters for named file fields

This commit is contained in:
Janis Goldschmidt 2021-02-22 11:50:28 +01:00
parent 2dbdf61c37
commit 986198ab8f
No known key found for this signature in database
GPG Key ID: CDCB5673C752F45B
1 changed files with 36 additions and 0 deletions

View File

@ -171,6 +171,42 @@ impl NamedFile {
self.path.as_path()
}
/// Retrieve the time the file was modified.
#[inline]
pub fn modified(&self) -> Option<&SystemTime> {
self.modified.as_ref()
}
/// Retrieve the metadata associated with this file.
#[inline]
pub fn md(&self) -> &Metadata {
&self.md
}
/// Retrieve the value of the `ContentType` header for serving this file.
#[inline]
pub fn content_type(&self) -> &mime::Mime {
&self.content_type
}
/// Retrieve the value of the `ContentDisposition` header for serving this file.
#[inline]
pub fn content_disposition(&self) -> &header::ContentDisposition {
&self.content_disposition
}
/// Retrieve the content encoding for serving this file.
#[inline]
pub fn encoding(&self) -> Option<&ContentEncoding> {
self.encoding.as_ref()
}
/// Retrieve the status code for serving this file.
#[inline]
pub fn status_code(&self) -> &StatusCode {
&self.status_code
}
/// Set response **Status Code**
pub fn set_status_code(mut self, status: StatusCode) -> Self {
self.status_code = status;