pub struct Client { /* private fields */ }Expand description
The client is the main entry point to access the obs-websocket API. It allows to call various functions to remote control an OBS instance as well as to listen to events caused by the user by interacting with OBS.
Implementations
sourceimpl Client
impl Client
sourcepub async fn connect(
host: impl AsRef<str>,
port: u16,
password: Option<impl AsRef<str>>
) -> Result<Self>
pub async fn connect(
host: impl AsRef<str>,
port: u16,
password: Option<impl AsRef<str>>
) -> Result<Self>
Connect to a obs-websocket instance on the given host and port.
sourcepub async fn connect_with_config<H, P>(
config: ConnectConfig<H, P>
) -> Result<Self> where
H: AsRef<str>,
P: AsRef<str>,
pub async fn connect_with_config<H, P>(
config: ConnectConfig<H, P>
) -> Result<Self> where
H: AsRef<str>,
P: AsRef<str>,
Connect to a obs-websocket instance with the given configuration.
sourcepub fn disconnect(&mut self) -> impl Future
pub fn disconnect(&mut self) -> impl Future
Disconnect from obs-websocket and shut down all machinery.
This is called automatically when dropping the client but doesn’t wait for all background tasks to complete. Therefore, it is recommended to call this manually once the client is no longer needed.
sourcepub async fn reidentify(
&self,
event_subscriptions: EventSubscription
) -> Result<()>
pub async fn reidentify(
&self,
event_subscriptions: EventSubscription
) -> Result<()>
Adjust settings of the currently active connection by re-identifying against
obs-websocket.
This currently allows to change the events to listen for, without the need of a full disconnect and new connection.
sourcepub fn events(&self) -> Result<impl Stream<Item = Event>>
pub fn events(&self) -> Result<impl Stream<Item = Event>>
Get a stream of events. Each call to this function creates a new listener, therefore it’s recommended to keep the stream around and iterate over it.
Note: To be able to iterate over the stream you have to pin it with
futures_util::pin_mut for example.
Errors
Getting a new stream of events fails with Error::Disconnected if the client is
disconnected from obs-websocket. That can happen either by manually disconnecting, stopping
obs-websocket or closing OBS.
sourcepub fn media_inputs(&self) -> MediaInputs<'_>
pub fn media_inputs(&self) -> MediaInputs<'_>
Access API functions related to media inputs.
sourcepub fn replay_buffer(&self) -> ReplayBuffer<'_>
pub fn replay_buffer(&self) -> ReplayBuffer<'_>
Access API functions related to the replay buffer.
sourcepub fn scene_collections(&self) -> SceneCollections<'_>
pub fn scene_collections(&self) -> SceneCollections<'_>
Access API functions related to scene collections.
sourcepub fn scene_items(&self) -> SceneItems<'_>
pub fn scene_items(&self) -> SceneItems<'_>
Access API functions related to scene items.
sourcepub fn transitions(&self) -> Transitions<'_>
pub fn transitions(&self) -> Transitions<'_>
Access API functions related to transitions.
sourcepub fn virtual_cam(&self) -> VirtualCam<'_>
pub fn virtual_cam(&self) -> VirtualCam<'_>
Access API functions related to the virtual camera.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl !UnwindSafe for Client
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
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
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more