Struct 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

Source

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"));
Source

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);
Source

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);
Source

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"));
Source

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"));
Source

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");
Source

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);
Source

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);
Source

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"));
Source

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

Source§

impl Clone for FileConfig

Source§

fn clone(&self) -> FileConfig

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for FileConfig

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for FileConfig

Source§

fn default() -> FileConfig

Returns the “default value” for a type. Read more
Source§

impl From<&Path> for FileConfig

Source§

fn from(path: &Path) -> Self

Converts to this type from the input type.
Source§

impl From<PathBuf> for FileConfig

Source§

fn from(path_buf: PathBuf) -> Self

Converts to this type from the input type.
Source§

impl TryFrom<&FileConfig> for BodyRead

Source§

type Error = GraphFailure

The type returned in the event of a conversion error.
Source§

fn try_from(file_config: &FileConfig) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<FileConfig> for BodyRead

Source§

type Error = GraphFailure

The type returned in the event of a conversion error.
Source§

fn try_from(file_config: FileConfig) -> Result<Self, Self::Error>

Performs the conversion.
Source§

impl TryFrom<FileConfig> for BytesMut

Source§

type Error = GraphFailure

The type returned in the event of a conversion error.
Source§

fn try_from(file_config: FileConfig) -> Result<Self, Self::Error>

Performs the conversion.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T