ObsBootstrapper

Struct ObsBootstrapper 

Source
pub struct ObsBootstrapper {}
Expand description

A struct for bootstrapping OBS Studio.

This struct provides functionality to download, extract, and set up OBS Studio for use with libobs-rs. It also handles updates to OBS when necessary.

If you want to use this bootstrapper to also install required OBS binaries at runtime, do the following:

  • Add a obs.dll file to your executable directory. This file will be replaced by the obs installer. Recommended to use is the dll dummy (found here, make sure you use the correct OBS version) and rename it to obs.dll.
  • Call ObsBootstrapper::bootstrap() at the start of your application. Options must be configured. For more documentation look at the tauri example app. This will download the latest version of OBS and extract it in the executable directory.
  • If BootstrapStatus::RestartRequired is returned, you’ll need to restart your application. A updater process has been spawned to watch for the application to exit and rename the obs_new.dll file to obs.dll.
  • Exit the application. The updater process will wait for the application to exit and rename the obs_new.dll file to obs.dll and restart your application with the same arguments as before.

Example project

Implementations§

Source§

impl ObsBootstrapper

A convenience type that exposes high-level helpers to detect, update and bootstrap an OBS installation.

The bootstrapper coordinates version checks and the streaming bootstrap process. It does not itself perform low-level network or extraction work; instead it delegates to internal modules (version checking and the bootstrap stream) and surfaces a simple API for callers.

Source

pub fn is_valid_installation() -> Result<bool, ObsBootstrapError>

Returns true if a valid OBS installation (as determined by locating the OBS DLL and querying the installed version) is present on the system.

§Returns
  • Ok(true) if an installed OBS version could be detected.
  • Ok(false) if no installed OBS version was found.
§Errors

Returns an Err(ObsBootstrapError) if there was an error locating the OBS DLL or reading the installed version information.

Source

pub fn is_update_available() -> Result<bool, ObsBootstrapError>

Returns true when an update to OBS should be performed.

The function first checks whether OBS is installed. If no installation is found it treats that as an available update (returns Ok(true)). Otherwise it consults the internal version logic to determine whether the installed version should be updated.

§Returns
  • Ok(true) when an update is recommended or when OBS is not installed.
  • Ok(false) when the installed version is up-to-date.
§Errors

Returns an Err(ObsBootstrapError) if there was an error locating the OBS DLL or determining the currently installed version or update necessity.

Source

pub async fn bootstrap( options: &ObsBootstrapperOptions, ) -> Result<ObsBootstrapperResult, ObsBootstrapError>

Bootstraps OBS using the provided options and a default console status handler.

This is a convenience wrapper around bootstrap_with_handler that supplies an ObsBootstrapConsoleHandler as the status consumer.

§Returns
  • Ok(ObsBootstrapperResult::None) if no action was necessary.
  • Ok(ObsBootstrapperResult::Restart) if the bootstrap completed and a restart is required.
§Errors

Returns Err(ObsBootstrapError) for any failure that prevents the bootstrap from completing (download failures, extraction failures, general errors).

Source

pub async fn bootstrap_with_handler<E: Send + Sync + 'static + Error>( options: &ObsBootstrapperOptions, handler: Box<dyn ObsBootstrapStatusHandler<Error = E>>, ) -> Result<ObsBootstrapperResult, ObsBootstrapError>

Bootstraps OBS using the provided options and a custom status handler.

The handler will receive progress updates as the bootstrap stream emits statuses. The method drives the bootstrap stream to completion and maps stream statuses into handler calls or final results:

  • BootstrapStatus::Downloading(progress, message) → calls handler.handle_downloading(progress, message). Handler errors are mapped to ObsBootstrapError::DownloadError.
  • BootstrapStatus::Extracting(progress, message) → calls handler.handle_extraction(progress, message). Handler errors are mapped to ObsBootstrapError::ExtractError.
  • BootstrapStatus::Error(err) → returns Err(ObsBootstrapError::GeneralError(_)).
  • BootstrapStatus::RestartRequired → returns Ok(ObsBootstrapperResult::Restart).

If the underlying bootstrap(options) call returns None there is nothing to do and the function returns Ok(ObsBootstrapperResult::None).

§Parameters
  • options: configuration that controls download/extraction behavior.
  • handler: user-provided boxed trait object that receives progress notifications; it is called on each progress update and can fail.
§Returns
  • Ok(ObsBootstrapperResult::None) when no work was required or the stream completed without requiring a restart.
  • Ok(ObsBootstrapperResult::Restart) when the bootstrap succeeded and a restart is required.
§Errors

Returns Err(ObsBootstrapError) when:

  • the bootstrap pipeline could not be started,
  • the handler returns an error while handling a download or extraction update (mapped respectively to DownloadError / ExtractError),
  • or when the bootstrap stream yields a general error.

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> 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: 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: 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> 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<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