Skip to main content

File

Trait File 

Source
pub trait File {
    // Required methods
    fn content(&self) -> &[u8] ;
    fn content_gzip(&self) -> Option<&[u8]>;
    fn content_brotli(&self) -> Option<&[u8]>;
    fn content_type(&self) -> HeaderValue;
    fn etag(&self) -> HeaderValue;
    fn cache_control(&self) -> CacheControl;
}
Expand description

Trait for single file inside a pack. Consists of body in different encodings (identity aka normal, gzip, brotli), some precomputed header values etc.

Most users will indirectly use FileArchived implementation, obtained from crate::pack::Pack::get_file_by_path (implemented by crate::common::pack::PackArchived). This trait is also implemented for non-archived File_, mostly for testing purposes.

Required Methods§

Source

fn content(&self) -> &[u8]

Accesses file content in original (identity) encoding.

Source

fn content_gzip(&self) -> Option<&[u8]>

Accesses file content in gzip encoding if available.

Source

fn content_brotli(&self) -> Option<&[u8]>

Accesses file content in brotli encoding if available.

Source

fn content_type(&self) -> HeaderValue

Accesses content-type header contents for this file.

Source

fn etag(&self) -> HeaderValue

Accesses ETag header contents for this file.

Source

fn cache_control(&self) -> CacheControl

Accesses CacheControl for this file.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementations on Foreign Types§

Source§

impl File for File

Source§

impl File for FileArchived

Implementors§