mirror of
https://github.com/OMGeeky/google-apis-rs.git
synced 2026-01-22 11:11:25 +01:00
feat(architecture): figure out ownership model
There is a central `YouTube` type which helps constructing various sub-builders, which in turn provide individual functions. Architecturally, it's very similar to the go implementation, but more efficient memory wise.
This commit is contained in:
28
src/common.rs
Normal file
28
src/common.rs
Normal file
@@ -0,0 +1,28 @@
|
||||
/// Identifies the an OAuth2 authorization scope.
|
||||
/// A scope is needed when requesting an
|
||||
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
|
||||
pub enum Scope {
|
||||
/// Manage your YouTube account
|
||||
Account,
|
||||
/// View your YouTube account
|
||||
AccountReadOnly,
|
||||
/// Manage your YouTube videos, which includes uploads and meta-data changes
|
||||
Video,
|
||||
/// View and manage your assets and associated content on YouTube
|
||||
Partner,
|
||||
/// View private information of your YouTube channel relevant during the
|
||||
/// audit process with a YouTube partner.
|
||||
Audit,
|
||||
}
|
||||
|
||||
impl Str for Scope {
|
||||
fn as_slice(&self) -> &str {
|
||||
match *self {
|
||||
Scope::Account => "https://www.googleapis.com/auth/youtube",
|
||||
Scope::AccountReadOnly => "https://www.googleapis.com/auth/youtube.readonly",
|
||||
Scope::Video => "https://www.googleapis.com/auth/youtube.upload",
|
||||
Scope::Partner => "https://www.googleapis.com/auth/youtubepartner",
|
||||
Scope::Audit => "https://www.googleapis.com/auth/youtubepartner-channel-audit",
|
||||
}
|
||||
}
|
||||
}
|
||||
35
src/videos.rs
Normal file
35
src/videos.rs
Normal file
@@ -0,0 +1,35 @@
|
||||
use std::cell::RefCell;
|
||||
use std::borrow::BorrowMut;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
use hyper;
|
||||
|
||||
pub struct VideosService<'a, C, NC>
|
||||
where NC: 'a,
|
||||
C: 'a {
|
||||
|
||||
client: &'a RefCell<C>,
|
||||
|
||||
_m: PhantomData<NC>
|
||||
}
|
||||
|
||||
impl<'a, C, NC> VideosService<'a, C, NC>
|
||||
where NC: hyper::net::NetworkConnector,
|
||||
C: BorrowMut<hyper::Client<NC>> + 'a {
|
||||
|
||||
pub fn new(client: &'a RefCell<C>) -> VideosService<'a, C, NC> {
|
||||
VideosService {
|
||||
client: client,
|
||||
_m: PhantomData,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user