Struct graph_http::api_impl::FileConfig
source · 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 given 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<&FileConfig> for &FileConfig
impl BodyExt<&FileConfig> 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 more