pub struct Host { /* private fields */ }Expand description
Represents a GitHub host (github.com or a GHES instance).
Implementations§
Source§impl Host
impl Host
Sourcepub fn new(hostname: &str) -> Self
pub fn new(hostname: &str) -> Self
Create a new Host for the given hostname.
For github.com, the API base is https://api.github.com.
For GHES instances, the API base is https://<hostname>/api/v3.
§Examples
use gor::host::Host;
let host = Host::new("github.com");
assert_eq!(host.api_base(), "https://api.github.com");
let ghes = Host::new("git.example.com");
assert_eq!(ghes.api_base(), "https://git.example.com/api/v3");Sourcepub fn api_url(&self, path: &str) -> String
pub fn api_url(&self, path: &str) -> String
Build a full API URL by joining the API base with the given path.
The path should start with a /, e.g. /user or /repos/owner/repo.
§Examples
use gor::host::Host;
let host = Host::new("github.com");
assert_eq!(host.api_url("/user"), "https://api.github.com/user");Sourcepub fn device_code_url(&self) -> String
pub fn device_code_url(&self) -> String
Build the OAuth device code URL for this host.
§Examples
use gor::host::Host;
let host = Host::new("github.com");
assert_eq!(
host.device_code_url(),
"https://github.com/login/device/code"
);Sourcepub fn access_token_url(&self) -> String
pub fn access_token_url(&self) -> String
Build the OAuth access token URL for this host.
§Examples
use gor::host::Host;
let host = Host::new("github.com");
assert_eq!(
host.access_token_url(),
"https://github.com/login/oauth/access_token"
);Sourcepub fn device_activation_url(&self) -> String
pub fn device_activation_url(&self) -> String
Build the device activation URL shown to the user.
§Examples
use gor::host::Host;
let host = Host::new("github.com");
assert_eq!(host.device_activation_url(), "https://github.com/login/device");Trait Implementations§
impl Eq for Host
impl StructuralPartialEq for Host
Auto Trait Implementations§
impl Freeze for Host
impl RefUnwindSafe for Host
impl Send for Host
impl Sync for Host
impl Unpin for Host
impl UnsafeUnpin for Host
impl UnwindSafe for Host
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.