[][src]Struct onedrive_api::OneDrive

pub struct OneDrive { /* fields omitted */ }

The authorized client to access OneDrive resources in a specified Drive.

Implementations

impl OneDrive[src]

pub fn new(access_token: String, drive: impl Into<DriveLocation>) -> Self[src]

Create a new OneDrive instance with access token given to perform operations in a Drive.

pub fn new_with_client(
    client: Client,
    access_token: String,
    drive: impl Into<DriveLocation>
) -> Self
[src]

Same as OneDrive::new but with custom reqwest::Client.

Note

The given client should have redirection disabled to make get_item_download_url[_with_option] work properly. See also the docs of get_item_download_url[_with_option].

pub fn access_token(&self) -> &str[src]

Get the access token used to create the OneDrive instance.

pub async fn get_drive_with_option(
    &self,
    option: ObjectOption<DriveField>
) -> Result<Drive>
[src]

Get current Drive.

Retrieve the properties and relationships of a resource::Drive resource.

See also

Microsoft Docs

pub async fn get_drive(&self) -> Result<Drive>[src]

Shortcut to get_drive_with_option with default parameters.

See also

get_drive_with_option

pub async fn list_children_with_option<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    option: CollectionOption<DriveItemField>
) -> Result<Option<ListChildrenFetcher>>
[src]

List children of a DriveItem.

Retrieve a collection of resource::DriveItems in the children relationship of the given one.

Response

If successful, respond a fetcher for fetching changes from initial state (empty) to the snapshot of current states. See ListChildrenFetcher for more details.

If if_none_match is set and it matches the item tag, return an None.

See also

Microsoft Docs

pub async fn list_children<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>
) -> Result<Vec<DriveItem>>
[src]

Shortcut to list_children_with_option with default params, and fetch and collect all children.

See also

list_children_with_option

pub async fn get_item_with_option<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    option: ObjectOption<DriveItemField>
) -> Result<Option<DriveItem>>
[src]

Get a DriveItem resource.

Retrieve the metadata for a resource::DriveItem by file system path or ID.

Errors

Will return Ok(None) if if_none_match is set and it matches the item tag.

See also

Microsoft Docs

pub async fn get_item<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>
) -> Result<DriveItem>
[src]

Shortcut to get_item_with_option with default parameters.

See also

get_item_with_option

pub async fn get_item_download_url_with_option<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    option: ObjectOption<DriveItemField>
) -> Result<String>
[src]

Get a pre-authorized download URL for a file.

The URL returned is only valid for a short period of time (a few minutes).

Note

This API only works with reqwest redirection disabled, which is the default option set by OneDrive::new(). If the OneDrive instance is created by new_with_client(), be sure the reqwest::Client has redirection disabled.

Only If-None-Match is supported in option.

See also

Microsoft Docs

pub async fn get_item_download_url<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>
) -> Result<String>
[src]

pub async fn create_folder_with_option<'a>(
    &self,
    parent_item: impl Into<ItemLocation<'a>>,
    name: &FileName,
    option: DriveItemPutOption
) -> Result<DriveItem>
[src]

Create a new folder under an DriveItem

Create a new folder DriveItem with a specified parent item or path.

Errors

Will result in Err with HTTP 409 CONFLICT if conflict_behavior is set to Fail and the target already exists.

See also

Microsoft Docs

pub async fn create_folder<'a>(
    &self,
    parent_item: impl Into<ItemLocation<'a>>,
    name: &FileName
) -> Result<DriveItem>
[src]

Shortcut to create_folder_with_option with default options.

See also

create_folder_with_option

pub async fn update_item_with_option<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    patch: &DriveItem,
    option: ObjectOption<DriveItemField>
) -> Result<DriveItem>
[src]

Update DriveItem properties

Update the metadata for a DriveItem.

If you want to rename or move an DriveItem to another place, you should use move_ (or move_with_option) instead of this, which is a wrapper to this API endpoint to make things easier.

See also

Microsoft Docs

pub async fn update_item<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    patch: &DriveItem
) -> Result<DriveItem>
[src]

Shortcut to update_item_with_option with default options.

See also

update_item_with_option

pub async fn upload_small<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    data: impl Into<Bytes>
) -> Result<DriveItem>
[src]

Upload or replace the contents of a DriveItem file.

The simple upload API allows you to provide the contents of a new file or update the contents of an existing file in a single API call. This method only supports files up to 4MB in size.

Panic

Panic if data is larger than 4 MB (4,000,000 bytes).

See also

Microsoft Docs

pub async fn new_upload_session_with_option<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    option: DriveItemPutOption,
    file_size: u64
) -> Result<UploadSession>
[src]

Create an upload session.

Create an upload session to allow your app to upload files up to the maximum file size. An upload session allows your app to upload ranges of the file in sequential API requests, which allows the transfer to be resumed if a connection is dropped while the upload is in progress.

Errors

Will return Err with HTTP 412 PRECONDITION_FAILED if if_match is set but does not match the item.

Note

conflict_behavior is supported.

file_size is actually NOT a part of this request, but is used to be stored in UploadSession and will be sent in upload_part() requests.

See also

Microsoft Docs

pub async fn new_upload_session<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    file_size: u64
) -> Result<UploadSession>
[src]

Shortcut to new_upload_session_with_option with ConflictBehavior::Fail.

See also

new_upload_session_with_option

pub async fn get_upload_session(
    &self,
    upload_url: String,
    file_size: u64
) -> Result<UploadSession>
[src]

Resuming an in-progress upload

Query the status of the upload to find out which byte ranges have been received previously.

Note

file_size is not saved by server but is required by UploadSession::upload_part(). You need to store it somewhere to make it possible to resume the session.

See also

Microsoft Docs

pub async fn copy<'a, 'b>(
    &self,
    source_item: impl Into<ItemLocation<'a>>,
    dest_folder: impl Into<ItemLocation<'b>>,
    dest_name: &FileName
) -> Result<CopyProgressMonitor>
[src]

Copy a DriveItem.

Asynchronously creates a copy of an driveItem (including any children), under a new parent item or with a new name.

Note

The conflict behavior is not mentioned in Microsoft Docs, and cannot be specified.

But it seems to behave as Rename if the destination folder is just the current parent folder, and Fail overwise.

See also

Microsoft Docs

pub async fn move_with_option<'a, 'b>(
    &self,
    source_item: impl Into<ItemLocation<'a>>,
    dest_folder: impl Into<ItemLocation<'b>>,
    dest_name: Option<&FileName>,
    option: DriveItemPutOption
) -> Result<DriveItem>
[src]

Move a DriveItem to a new folder.

This is a special case of the Update method. Your app can combine moving an item to a new container and updating other properties of the item into a single request.

Note: Items cannot be moved between Drives using this request.

Note

conflict_behavior is supported.

Errors

Will return Err with HTTP 412 PRECONDITION_FAILED if if_match is set but it does not match the item.

See also

Microsoft Docs

pub async fn move_<'a, 'b>(
    &self,
    source_item: impl Into<ItemLocation<'a>>,
    dest_folder: impl Into<ItemLocation<'b>>,
    dest_name: Option<&FileName>
) -> Result<DriveItem>
[src]

Shortcut to move_with_option with ConflictBehavior::Fail.

See also

move_with_option

pub async fn delete_with_option<'a>(
    &self,
    item: impl Into<ItemLocation<'a>>,
    option: DriveItemPutOption
) -> Result<()>
[src]

Delete a DriveItem.

Delete a DriveItem by using its ID or path. Note that deleting items using this method will move the items to the recycle bin instead of permanently deleting the item.

Error

Will result in error with HTTP 412 PRECONDITION_FAILED if if_match is set but does not match the item.

Panic

conflict_behavior is NOT supported. Set it will cause a panic.

See also

Microsoft Docs

pub async fn delete<'a>(&self, item: impl Into<ItemLocation<'a>>) -> Result<()>[src]

Shortcut to delete_with_option.

See also

delete_with_option

pub async fn track_root_changes_from_initial_with_option<'a>(
    &self,
    option: CollectionOption<DriveItemField>
) -> Result<TrackChangeFetcher>
[src]

Track changes for root folder from initial state (empty state) to snapshot of current states.

This method allows your app to track changes to a drive and its children over time. Deleted items are returned with the deleted facet. Items with this property set should be removed from your local state.

Note: you should only delete a folder locally if it is empty after syncing all the changes.

Panic

Track Changes API does not support $count=true query parameter. If CollectionOption::get_count is set in option, it will panic.

Response

Respond a fetcher for fetching changes from initial state (empty) to the snapshot of current states. See TrackChangeFetcher for more details.

See also

Microsoft Docs

pub async fn track_root_changes_from_initial<'a>(
    &self
) -> Result<TrackChangeFetcher>
[src]

Shortcut to track_root_changes_from_initial_with_option with default parameters.

See also

track_root_changes_from_initial_with_option

pub async fn track_root_changes_from_delta_url(
    &self,
    delta_url: &str
) -> Result<TrackChangeFetcher>
[src]

Track changes for root folder from snapshot (delta url) to snapshot of current states.

Note

There is no with_option version of this function. Since delta URL already carries query parameters when you get it. The initial parameters will be automatically used in all following requests through delta URL.

pub async fn get_root_latest_delta_url_with_option<'a>(
    &self,
    option: CollectionOption<DriveItemField>
) -> Result<String>
[src]

Get a delta url representing the snapshot of current states of root folder.

The delta url can be used in track_root_changes_from_delta_url later to get diffs between two snapshots of states.

Note that options (query parameters) are saved in delta url, so they are applied to all later requests by track_changes_from_delta_url without need for specifying them every time.

Panic

Track Changes API does not support $count=true query parameter. If CollectionOption::get_count is set in option, it will panic.

See also

Microsoft Docs

pub async fn get_root_latest_delta_url<'a>(&self) -> Result<String>[src]

Shortcut to get_root_latest_delta_url_with_option with default parameters.

See also

get_root_latest_delta_url_with_option

Trait Implementations

impl Debug for OneDrive[src]

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T> Instrument for T[src]

impl<T> Instrument for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.