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:
Sebastian Thiel
2015-02-28 15:42:52 +01:00
parent dda847607f
commit 67b052c5f3
2 changed files with 63 additions and 0 deletions

28
src/common.rs Normal file
View 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
View 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 {
}