Skip to main content

Update

Struct Update 

Source
pub struct Update { /* private fields */ }
Expand description

Wraps a ReleaseUpdate and redirects file descriptor 1 while it runs.

Before delegating to the inner update, fd 1 is pointed at the configured Sink; once the update returns (successfully or not) the original fd 1 is restored. Because the redirect happens at the descriptor level, output from spawned child processes and native code is diverted too.

§Platform behavior

  • Unix: fd 1 is duplicated and swapped via dup/dup2.
  • Windows: the process’s standard-output handle is swapped via GetStdHandle/SetStdHandle (pointed at the NUL device or the standard-error handle). Rust’s std re-queries GetStdHandle on every write, so its output honors the swap for the duration of the update.
  • Other platforms: redirection is unsupported, so the wrapped update runs unchanged (no redirect is applied).

§Metadata

All metadata methods (including no_confirm, show_output, and show_download_progress) delegate to the wrapped update. Because a backend reads its own configuration when it runs, overriding those on the wrapper would not change the behavior of an arbitrarily deep composition, so this wrapper relies solely on the fd redirect to keep the update quiet.

Implementations§

Source§

impl Update

Source

pub fn configure() -> UpdateBuilder

Initialize a new Update builder.

Source

pub fn sink(&self) -> Sink

The Sink fd 1 is redirected to while the wrapped update runs.

Trait Implementations§

Source§

impl ReleaseUpdate for Update

Source§

fn get_latest_release(&self) -> Result<Release>

Fetch details of the latest release from the backend
Source§

fn get_latest_releases(&self, current_version: &str) -> Result<Vec<Release>>

Fetch details of the latest release from the backend
Source§

fn get_release_version(&self, ver: &str) -> Result<Release>

Fetch details of the release matching the specified version
Source§

fn current_version(&self) -> String

Current version of binary being updated
Source§

fn target(&self) -> String

Target platform the update is being performed for
Source§

fn target_version(&self) -> Option<String>

Target version optionally specified for the update
Source§

fn bin_name(&self) -> String

Name of the binary being updated
Source§

fn bin_install_path(&self) -> PathBuf

Installation path for the binary being updated
Source§

fn bin_path_in_archive(&self) -> String

Path of the binary to be extracted from release package
Source§

fn show_download_progress(&self) -> bool

Flag indicating if progress information shall be output when downloading a release
Source§

fn show_output(&self) -> bool

Flag indicating if process informative messages shall be output
Source§

fn no_confirm(&self) -> bool

Flag indicating if the user shouldn’t be prompted to confirm an update
Source§

fn progress_template(&self) -> String

Source§

fn progress_chars(&self) -> String

Source§

fn auth_token(&self) -> Option<String>

Authorisation token for communicating with backend
Source§

fn update(&self) -> Result<Status>

Display release information and update the current binary to the latest release, pending confirmation from the user
Source§

fn update_extended(&self) -> Result<UpdateStatus>

Same as update, but returns UpdateStatus.
Source§

fn identifier(&self) -> Option<String>

Optional identifier of determining the asset among multiple matches
Source§

fn api_headers(&self, auth_token: &Option<String>) -> Result<HeaderMap, Error>

Construct a header with an authorisation entry if an auth token is provided

Auto Trait Implementations§

§

impl !RefUnwindSafe for Update

§

impl !Send for Update

§

impl !Sync for Update

§

impl !UnwindSafe for Update

§

impl Freeze for Update

§

impl Unpin for Update

§

impl UnsafeUnpin for Update

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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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<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