Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 67b052c

Browse files
committed
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.
1 parent dda8476 commit 67b052c

2 files changed

Lines changed: 63 additions & 0 deletions

File tree

src/common.rs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
/// Identifies the an OAuth2 authorization scope.
2+
/// A scope is needed when requesting an
3+
/// [authorization token](https://developers.google.com/youtube/v3/guides/authentication).
4+
pub enum Scope {
5+
/// Manage your YouTube account
6+
Account,
7+
/// View your YouTube account
8+
AccountReadOnly,
9+
/// Manage your YouTube videos, which includes uploads and meta-data changes
10+
Video,
11+
/// View and manage your assets and associated content on YouTube
12+
Partner,
13+
/// View private information of your YouTube channel relevant during the
14+
/// audit process with a YouTube partner.
15+
Audit,
16+
}
17+
18+
impl Str for Scope {
19+
fn as_slice(&self) -> &str {
20+
match *self {
21+
Scope::Account => "https://www.googleapis.com/auth/youtube",
22+
Scope::AccountReadOnly => "https://www.googleapis.com/auth/youtube.readonly",
23+
Scope::Video => "https://www.googleapis.com/auth/youtube.upload",
24+
Scope::Partner => "https://www.googleapis.com/auth/youtubepartner",
25+
Scope::Audit => "https://www.googleapis.com/auth/youtubepartner-channel-audit",
26+
}
27+
}
28+
}

src/videos.rs

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
use std::cell::RefCell;
2+
use std::borrow::BorrowMut;
3+
use std::marker::PhantomData;
4+
5+
use hyper;
6+
7+
pub struct VideosService<'a, C, NC>
8+
where NC: 'a,
9+
C: 'a {
10+
11+
client: &'a RefCell<C>,
12+
13+
_m: PhantomData<NC>
14+
}
15+
16+
impl<'a, C, NC> VideosService<'a, C, NC>
17+
where NC: hyper::net::NetworkConnector,
18+
C: BorrowMut<hyper::Client<NC>> + 'a {
19+
20+
pub fn new(client: &'a RefCell<C>) -> VideosService<'a, C, NC> {
21+
VideosService {
22+
client: client,
23+
_m: PhantomData,
24+
}
25+
}
26+
}
27+
28+
29+
30+
#[cfg(test)]
31+
mod tests {
32+
33+
34+
35+
}

0 commit comments

Comments
 (0)