pub struct FileConfig {
pub path: PathBuf,
pub create_directory_all: bool,
pub overwrite_existing_file: bool,
pub file_name: Option<OsString>,
pub extension: Option<OsString>,
}
Expand description
Config for downloading files using Microsoft Graph File and OneDrive APIs. FileConfig can also be used for uploads but all fields except for the provided path are ignored.
§Example
use std::ffi::{OsStr, OsString};
use std::path::Path;
use graph_http::api_impl::FileConfig;
let config = FileConfig::new("./examples")
.file_name(OsStr::new("example.json"));
§Example
use std::ffi::{OsStr, OsString};
use std::path::Path;
use graph_http::api_impl::FileConfig;
let config = FileConfig::new("./examples")
.overwrite_existing_file(true)
.extension(OsStr::new("pdf"));
Fields§
§path: PathBuf
§create_directory_all: bool
Used only when downloading files. Default is true.
overwrite_existing_file: bool
Used only when downloading files
file_name: Option<OsString>
Used only when downloading files
extension: Option<OsString>
Used only when downloading files
Implementations§
Source§impl FileConfig
impl FileConfig
Sourcepub fn new<P: AsRef<Path>>(path: P) -> FileConfig
pub fn new<P: AsRef<Path>>(path: P) -> FileConfig
Create the file configuration for downloading files.
§Example
use std::ffi::{OsStr, OsString};
use std::path::Path;
use graph_http::api_impl::FileConfig;
let config = FileConfig::new("./examples")
.create_directories(true)
.file_name(OsStr::new("example.json"));
§Example
use std::ffi::{OsStr, OsString};
use std::path::Path;
use graph_http::api_impl::FileConfig;
let config = FileConfig::new("./examples")
.overwrite_existing_file(true)
.extension(OsStr::new("pdf"));
Sourcepub fn create_directories(self, create_directories: bool) -> FileConfig
pub fn create_directories(self, create_directories: bool) -> FileConfig
Create all directories in the path given if they do not exist.
§Example
use graph_http::api_impl::FileConfig;
let config = FileConfig::new("./examples")
.create_directories(true);
Sourcepub fn overwrite_existing_file(self, overwrite_file: bool) -> FileConfig
pub fn overwrite_existing_file(self, overwrite_file: bool) -> FileConfig
Overwrite an existing file of the same file name and path. This is true by default.
§Example
use graph_http::api_impl::FileConfig;
let config = FileConfig::new("./examples")
.overwrite_existing_file(true);
Sourcepub fn file_name(self, file_name: &OsStr) -> FileConfig
pub fn file_name(self, file_name: &OsStr) -> FileConfig
Set the file name and extension. If you use the format ODataQuery to change the file type such as from JSON to PDF then you must provide a name for the file or the download will fail.
§Example
use std::ffi::{OsStr, OsString};
use graph_http::api_impl::FileConfig;
let config = FileConfig::new("./examples")
.file_name(OsStr::new("example.pdf"));
Sourcepub fn extension(self, ext: &OsStr) -> FileConfig
pub fn extension(self, ext: &OsStr) -> FileConfig
Set the extension of the file being downloaded. This only changes the extension name of the file and does not change the format of the file. You can change the format of the file using the ODataQuery format method such as changing from JSONto PDF
§Example
use std::ffi::{OsStr, OsString};
use graph_http::api_impl::FileConfig;
let config = FileConfig::new("./examples")
.extension(OsStr::new("pdf"));
Sourcepub fn set_path<P: AsRef<Path>>(&mut self, path: P)
pub fn set_path<P: AsRef<Path>>(&mut self, path: P)
Create all directories in the path if they do not exist.
§Example
use std::path::Path;
use graph_http::api_impl::FileConfig;
let mut config = FileConfig::default();
config.set_path("./examples");
Sourcepub fn set_create_directories(&mut self, create_directories: bool)
pub fn set_create_directories(&mut self, create_directories: bool)
Create all directories in the path given if they do not exist.
§Example
use graph_http::api_impl::FileConfig;
let mut config = FileConfig::new("./examples");
config.set_create_directories(true);
Sourcepub fn set_overwrite_existing_file(&mut self, overwrite_file: bool)
pub fn set_overwrite_existing_file(&mut self, overwrite_file: bool)
Overwrite an existing file of the same file name and path.
§Example
use graph_http::api_impl::FileConfig;
let mut config = FileConfig::new("./examples");
config.set_overwrite_existing_file(true);
Sourcepub fn set_file_name(&mut self, file_name: &OsStr)
pub fn set_file_name(&mut self, file_name: &OsStr)
Set the file name and extension. If you use the format ODataQuery to change the file type such as from JSON to PDF then you must provide a name for the file or the download will fail.
§Example
use std::ffi::{OsStr, OsString};
use graph_http::api_impl::FileConfig;
let mut config = FileConfig::new("./examples");
config.set_file_name(OsStr::new("example.pdf"));
Sourcepub fn set_extension(&mut self, ext: &OsStr)
pub fn set_extension(&mut self, ext: &OsStr)
Set the extension of the file being downloaded. This only changes the extension name of the file and does not change the format of the file. You can change the format of the file using the ODataQuery format method such as changing from JSONto PDF
§Example
use std::ffi::{OsStr, OsString};
use graph_http::api_impl::FileConfig;
let mut config = FileConfig::new("./examples")
.extension(OsStr::new("pdf"));
Trait Implementations§
Source§impl BodyExt for &FileConfig
impl BodyExt for &FileConfig
fn into_body(self) -> GraphResult<BodyRead>
Source§impl Clone for FileConfig
impl Clone for FileConfig
Source§fn clone(&self) -> FileConfig
fn clone(&self) -> FileConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreSource§impl Debug for FileConfig
impl Debug for FileConfig
Source§impl Default for FileConfig
impl Default for FileConfig
Source§fn default() -> FileConfig
fn default() -> FileConfig
Source§impl From<&Path> for FileConfig
impl From<&Path> for FileConfig
Source§impl From<PathBuf> for FileConfig
impl From<PathBuf> for FileConfig
Source§impl TryFrom<&FileConfig> for BodyRead
impl TryFrom<&FileConfig> for BodyRead
Source§type Error = GraphFailure
type Error = GraphFailure
Source§impl TryFrom<FileConfig> for BodyRead
impl TryFrom<FileConfig> for BodyRead
Source§type Error = GraphFailure
type Error = GraphFailure
Source§impl TryFrom<FileConfig> for BytesMut
impl TryFrom<FileConfig> for BytesMut
Source§type Error = GraphFailure
type Error = GraphFailure
Auto Trait Implementations§
impl Freeze for FileConfig
impl RefUnwindSafe for FileConfig
impl Send for FileConfig
impl Sync for FileConfig
impl Unpin for FileConfig
impl UnwindSafe for FileConfig
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more