ubi

Struct UbiBuilder

Source
pub struct UbiBuilder<'a> { /* private fields */ }
Expand description

UbiBuilder is used to create a Ubi instance.

Implementations§

Source§

impl<'a> UbiBuilder<'a>

Source

pub fn new() -> Self

Returns a new empty UbiBuilder.

Source

pub fn project(self, project: &'a str) -> Self

Set the project to download from. This can either be just the org/name, like houseabsolute/precious, or the complete forge site URL to the project, like https://github.com/houseabsolute/precious or https://gitlab.com/gitlab-org/cli. It also accepts a URL to any page in the project, like https://github.com/houseabsolute/precious/releases.

You must set this or set url, but not both.

Source

pub fn tag(self, tag: &'a str) -> Self

Set the tag to download. By default the most recent release is downloaded. You cannot set this with the url option.

Source

pub fn url(self, url: &'a str) -> Self

Set the URL to download from. This can be provided instead of a project or tag. This will not use the forge site API, so you will never hit API limits. That in turn means you won’t have to set a token env var except when downloading a release from a private repo when the URL is set.

You must set this or set project, but not both.

Source

pub fn install_dir(self, install_dir: PathBuf) -> Self

Set the directory to install the binary in. If not set, it will default to ./bin.

Source

pub fn matching(self, matching: &'a str) -> Self

Set a string to match against the release filename when there are multiple files for your OS/arch, i.e. “gnu” or “musl”. Note that this is only used when there is more than one matching release filename for your OS/arch. If only one release asset matches your OS/arch, then this will be ignored.

Source

pub fn exe(self, exe: &'a str) -> Self

Set the name of the executable to look for in archive files. By default this is the same as the project name, so for houseabsolute/precious we look for precious or precious.exe. When running on Windows the “.exe” suffix will be added as needed.

Source

pub fn github_token(self, token: &'a str) -> Self

Set a GitHub token to use for API requests. If this is not set then this will be taken from the GITHUB_TOKEN env var if it is set.

Source

pub fn gitlab_token(self, token: &'a str) -> Self

Set a GitLab token to use for API requests. If this is not set then this will be taken from the CI_JOB_TOKEN or GITLAB_TOKEN env var, if one of these is set. If both are set, then the value in CI_JOB_TOKEN will be used.

Source

pub fn platform(self, platform: &'a Platform) -> Self

Set the platform to download for. If not set it will be determined based on the current platform’s OS/arch.

Source

pub fn is_musl(self, is_musl: bool) -> Self

Set whether or not the platform uses musl as its libc. This is only relevant for Linux platforms. If this isn’t set then it will be determined based on the current platform’s libc. You cannot set this to true on a non-Linux platform.

Source

pub fn forge(self, forge: ForgeType) -> Self

Set the forge type to use for fetching assets and release information. This determines which REST API is used to get information about releases and to download the release. If this isn’t set, then this will be determined from the hostname in the url, if that is set. Otherwise, the default is GitHub.

Source

pub fn api_base_url(self, api_base_url: &'a str) -> Self

Set the base URL for the forge site’s API. This is useful for testing or if you want to operate against an Enterprise version of GitHub or GitLab. This should be something like https://github.my-corp.example.com/api/v4.

Source

pub fn build(self) -> Result<Ubi<'a>>

Builds a new Ubi instance and returns it.

§Errors

If you have tried to set incompatible options (setting a project or tag with a url) or you have not set required options (one of project or url), then this method will return an error.

Trait Implementations§

Source§

impl<'a> Debug for UbiBuilder<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Default for UbiBuilder<'a>

Source§

fn default() -> UbiBuilder<'a>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for UbiBuilder<'a>

§

impl<'a> RefUnwindSafe for UbiBuilder<'a>

§

impl<'a> Send for UbiBuilder<'a>

§

impl<'a> Sync for UbiBuilder<'a>

§

impl<'a> Unpin for UbiBuilder<'a>

§

impl<'a> UnwindSafe for UbiBuilder<'a>

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T