pub struct Registry<T: HttpClient> {
pub(crate) host: String,
pub(crate) token: Option<String>,
pub(crate) handle: T,
pub(crate) auth_required: bool,
}Fields§
§host: StringThe base URL for issuing API requests.
token: Option<String>Optional authorization token. If None, commands requiring authorization will fail.
handle: THTTP handle for issuing requests.
auth_required: boolWhether to include the authorization token with all requests.
Implementations§
Source§impl<T: HttpClient> Registry<T>
impl<T: HttpClient> Registry<T>
Sourcepub fn new_handle(
host: String,
token: Option<String>,
handle: T,
auth_required: bool,
) -> Self
pub fn new_handle( host: String, token: Option<String>, handle: T, auth_required: bool, ) -> Self
Creates a new Registry.
§Example
use crates_io::{Registry, HttpClient};
use http::{Request, Response};
struct Client {}
impl HttpClient for Client {
type Error = std::io::Error;
fn request(&self, req: Request<Vec<u8>>) -> Result<Response<Vec<u8>>, Self::Error> {
todo!()
}
}
let client = Client {};
let mut reg = Registry::new_handle(String::from("https://crates.io"), None, client, false);pub fn set_token(&mut self, token: Option<String>)
pub(crate) fn token(&self) -> Result<&str, Error<T::Error>>
pub fn host(&self) -> &str
pub fn host_is_crates_io(&self) -> bool
pub fn add_owners( &mut self, krate: &str, owners: &[&str], ) -> Result<String, Error<T::Error>>
pub fn remove_owners( &mut self, krate: &str, owners: &[&str], ) -> Result<(), Error<T::Error>>
pub fn list_owners(&mut self, krate: &str) -> Result<Vec<User>, Error<T::Error>>
pub fn publish( &mut self, krate: &NewCrate, tarball: &File, ) -> Result<Warnings, Error<T::Error>>
pub fn search( &mut self, query: &str, limit: u32, ) -> Result<(Vec<Crate>, u32), Error<T::Error>>
pub fn yank( &mut self, krate: &str, version: &str, ) -> Result<(), Error<T::Error>>
pub fn unyank( &mut self, krate: &str, version: &str, ) -> Result<(), Error<T::Error>>
pub(crate) fn put( &mut self, path: &str, b: Option<&[u8]>, ) -> Result<String, Error<T::Error>>
pub(crate) fn get(&mut self, path: &str) -> Result<String, Error<T::Error>>
pub(crate) fn delete( &mut self, path: &str, b: Option<&[u8]>, ) -> Result<String, Error<T::Error>>
pub(crate) fn api_url(&self, path: &str) -> String
pub(crate) fn req( &mut self, method: Method, path: &str, body: Option<&[u8]>, authorized: Auth, ) -> Result<String, Error<T::Error>>
pub(crate) fn handle( &mut self, response: Response<Vec<u8>>, ) -> Result<String, Error<T::Error>>
Auto Trait Implementations§
impl<T> Freeze for Registry<T>where
T: Freeze,
impl<T> RefUnwindSafe for Registry<T>where
T: RefUnwindSafe,
impl<T> Send for Registry<T>where
T: Send,
impl<T> Sync for Registry<T>where
T: Sync,
impl<T> Unpin for Registry<T>where
T: Unpin,
impl<T> UnsafeUnpin for Registry<T>where
T: UnsafeUnpin,
impl<T> UnwindSafe for Registry<T>where
T: UnwindSafe,
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
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.