Impl Clone for Files<S>

This commit is contained in:
Douman 2019-03-25 21:41:48 +03:00
parent b8f8e62fba
commit 62ab6cc252
1 changed files with 18 additions and 13 deletions

View File

@ -211,7 +211,6 @@ fn directory_listing(
type MimeOverride = Fn(&mime::Name) -> DispositionType; type MimeOverride = Fn(&mime::Name) -> DispositionType;
#[derive(Clone)]
/// Static files handling /// Static files handling
/// ///
/// `Files` service must be registered with `App::service()` method. /// `Files` service must be registered with `App::service()` method.
@ -238,6 +237,23 @@ pub struct Files<S> {
file_flags: named::Flags, file_flags: named::Flags,
} }
impl<S> Clone for Files<S> {
fn clone(&self) -> Self {
Self {
directory: self.directory.clone(),
index: self.index.clone(),
show_index: self.show_index,
default: self.default.clone(),
renderer: self.renderer.clone(),
_chunk_size: self._chunk_size,
_follow_symlinks: self._follow_symlinks,
file_flags: self.file_flags,
path: self.path.clone(),
mime_override: self.mime_override.clone(),
}
}
}
impl<S: 'static> Files<S> { impl<S: 'static> Files<S> {
/// Create new `Files` instance for specified base directory. /// Create new `Files` instance for specified base directory.
/// ///
@ -344,18 +360,7 @@ impl<P> NewService for Files<P> {
type Future = FutureResult<Self::Service, Self::InitError>; type Future = FutureResult<Self::Service, Self::InitError>;
fn new_service(&self, _: &()) -> Self::Future { fn new_service(&self, _: &()) -> Self::Future {
ok(Files { ok(self.clone())
directory: self.directory.clone(),
index: self.index.clone(),
show_index: self.show_index,
default: self.default.clone(),
renderer: self.renderer.clone(),
_chunk_size: self._chunk_size,
_follow_symlinks: self._follow_symlinks,
file_flags: self.file_flags,
path: self.path.clone(),
mime_override: self.mime_override.clone(),
})
} }
} }