changeset 41:a3d203a72475

Use new common crate async-google-apis-common.
author Lewin Bormann <lbo@spheniscida.de>
date Mon, 19 Oct 2020 12:11:39 +0200
parents ca165b8a8855
children 1f428b57807e
files drive_example/Cargo.lock drive_example/Cargo.toml drive_example/src/drive_v3_types.rs drive_example/src/main.rs
diffstat 4 files changed, 27 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/drive_example/Cargo.lock	Mon Oct 19 12:11:19 2020 +0200
+++ b/drive_example/Cargo.lock	Mon Oct 19 12:11:39 2020 +0200
@@ -13,6 +13,21 @@
 checksum = "4d25d88fd6b8041580a654f9d0c581a047baee2b3efee13275f2fc392fc75034"
 
 [[package]]
+name = "async-google-apis-common"
+version = "0.1.0"
+dependencies = [
+ "anyhow",
+ "chrono",
+ "hyper",
+ "hyper-rustls",
+ "percent-encoding",
+ "serde",
+ "serde_json",
+ "tokio",
+ "yup-oauth2",
+]
+
+[[package]]
 name = "autocfg"
 version = "1.0.1"
 source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -104,12 +119,10 @@
 version = "0.1.0"
 dependencies = [
  "anyhow",
- "chrono",
+ "async-google-apis-common",
  "hyper",
  "hyper-rustls",
- "percent-encoding",
  "serde",
- "serde_json",
  "tokio",
  "yup-oauth2",
 ]
--- a/drive_example/Cargo.toml	Mon Oct 19 12:11:19 2020 +0200
+++ b/drive_example/Cargo.toml	Mon Oct 19 12:11:39 2020 +0200
@@ -7,12 +7,11 @@
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
 
 [dependencies]
+async-google-apis-common = { path = "../async-google-apis-common/" }
+
+serde = "~1.0"
 anyhow = "~1.0"
-chrono = "~0.4"
 hyper = "~0.13"
 hyper-rustls = "~0.20"
-percent-encoding = "~2.1"
-serde = "~1.0"
-serde_json = "~1.0"
 tokio = { version = "~0.2", features = ["full"] }
 yup-oauth2 = "~4"
--- a/drive_example/src/drive_v3_types.rs	Mon Oct 19 12:11:19 2020 +0200
+++ b/drive_example/src/drive_v3_types.rs	Mon Oct 19 12:11:39 2020 +0200
@@ -8,29 +8,9 @@
 //!
 //! THIS FILE HAS BEEN GENERATED -- SAVE ANY MODIFICATIONS BEFORE REPLACING.
 
-use serde::{Deserialize, Serialize};
-use chrono::{DateTime, Utc};
-use anyhow::{Error, Result};
-use std::collections::HashMap;
-use tokio::stream::StreamExt;
-use percent_encoding::{percent_encode, NON_ALPHANUMERIC};
-
-pub type TlsConnr = hyper_rustls::HttpsConnector<hyper::client::HttpConnector>;
-pub type TlsClient = hyper::Client<TlsConnr, hyper::Body>;
-pub type Authenticator = yup_oauth2::authenticator::Authenticator<TlsConnr>;
-
-#[derive(Debug, Clone)]
-pub enum ApiError {
-  InputDataError(String),
-  HTTPError(hyper::StatusCode),
-}
-
-impl std::error::Error for ApiError {}
-impl std::fmt::Display for ApiError {
-  fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
-    std::fmt::Debug::fmt(self, f)
-  }
-}
+use async_google_apis_common::*;
+use async_google_apis_common::{Deserialize, Serialize};
+
 
 /// Scopes of this API. Convertible to their string representation with `AsRef`.
 #[derive(Debug, Clone, Copy)]
@@ -1055,7 +1035,7 @@
     #[serde(rename = "teamDriveId")]
     #[serde(skip_serializing_if = "Option::is_none")]
     pub team_drive_id: Option<String>,
-    /// A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Only populated when the requesting app can access the file's content.
+    /// A short-lived link to the file's thumbnail, if available. Typically lasts on the order of hours. Only populated when the requesting app can access the file's content. If the file isn't shared publicly, the URL returned in Files.thumbnailLink must be fetched using a credentialed request.
     #[serde(rename = "thumbnailLink")]
     #[serde(skip_serializing_if = "Option::is_none")]
     pub thumbnail_link: Option<String>,
@@ -3621,7 +3601,7 @@
 pub async fn export(
     &mut self, params: &FilesExportParams,  dst: &mut dyn std::io::Write) -> Result<()> {
 
-    let rel_path = format!("files/trash", );
+    let rel_path = format!("files/{fileId}/export", fileId=params.file_id);
     let path = "https://www.googleapis.com/drive/v3/".to_string() + &rel_path;
 
     let tok;
--- a/drive_example/src/main.rs	Mon Oct 19 12:11:19 2020 +0200
+++ b/drive_example/src/main.rs	Mon Oct 19 12:11:39 2020 +0200
@@ -9,12 +9,14 @@
 mod drive_v3_types;
 use drive_v3_types as drive;
 
+use async_google_apis_common as common;
+
 use std::rc::Rc;
 use std::fs;
 use std::path::Path;
 
 /// Create a new HTTPS client.
-fn https_client() -> drive::TlsClient {
+fn https_client() -> common::TlsClient {
     let conn = hyper_rustls::HttpsConnector::new();
     let cl = hyper::Client::builder().build(conn);
     cl