crates_io

Struct Registry

source
pub struct Registry {
    pub(crate) host: String,
    pub(crate) token: Option<String>,
    pub(crate) handle: Easy,
    pub(crate) auth_required: bool,
}

Fields§

§host: String

The base URL for issuing API requests.

§token: Option<String>

Optional authorization token. If None, commands requiring authorization will fail.

§handle: Easy

Curl handle for issuing requests.

§auth_required: bool

Whether to include the authorization token with all requests.

Implementations§

source§

impl Registry

source

pub fn new_handle( host: String, token: Option<String>, handle: Easy, auth_required: bool, ) -> Registry

Creates a new Registry.

§Example
use curl::easy::Easy;
use crates_io::Registry;

let mut handle = Easy::new();
// If connecting to crates.io, a user-agent is required.
handle.useragent("my_crawler (example.com/info)");
let mut reg = Registry::new_handle(String::from("https://crates.io"), None, handle, true);
source

pub fn set_token(&mut self, token: Option<String>)

source

pub(crate) fn token(&self) -> Result<&str>

source

pub fn host(&self) -> &str

source

pub fn host_is_crates_io(&self) -> bool

source

pub fn add_owners(&mut self, krate: &str, owners: &[&str]) -> Result<String>

source

pub fn remove_owners(&mut self, krate: &str, owners: &[&str]) -> Result<()>

source

pub fn list_owners(&mut self, krate: &str) -> Result<Vec<User>>

source

pub fn publish(&mut self, krate: &NewCrate, tarball: &File) -> Result<Warnings>

source

pub fn search(&mut self, query: &str, limit: u32) -> Result<(Vec<Crate>, u32)>

source

pub fn yank(&mut self, krate: &str, version: &str) -> Result<()>

source

pub fn unyank(&mut self, krate: &str, version: &str) -> Result<()>

source

pub(crate) fn put(&mut self, path: &str, b: &[u8]) -> Result<String>

source

pub(crate) fn get(&mut self, path: &str) -> Result<String>

source

pub(crate) fn delete(&mut self, path: &str, b: Option<&[u8]>) -> Result<String>

source

pub(crate) fn req( &mut self, path: &str, body: Option<&[u8]>, authorized: Auth, ) -> Result<String>

source

pub(crate) fn handle( &mut self, read: &mut dyn FnMut(&mut [u8]) -> usize, ) -> Result<String>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

source§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.

Layout§

Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...) attributes. Please see the Rust Reference's “Type Layout” chapter for details on type layout guarantees.

Size: 64 bytes