Skip to main content

VRChatOSC

Struct VRChatOSC 

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

Main struct for managing VRChat OSC communication and service discovery.

Implementations§

Source§

impl VRChatOSC

Source

pub async fn new(osc_ip: Option<IpAddr>) -> Result<Arc<VRChatOSC>, Error>

Creates a new VRChatOSC instance.

§Arguments
  • osc_ip - Optional destination IP address for OSC messages. If None, it will attempt to automatically find a suitable network interface.
Source

pub async fn set_osc_ip(&self, ip: IpAddr) -> Result<(), Error>

Sets the destination IP address for OSC messages.

§Arguments
  • ip - The new destination IP address.
Source

pub async fn get_osc_ip(&self) -> IpAddr

Gets the currently configured OSC destination IP address.

Source

pub async fn on_connect<F>(&self, callback: F)
where F: Fn(ServiceType) + Send + Sync + 'static,

Registers a callback to be invoked when a new OSC service is discovered on the network.

§Arguments
  • callback - A function or closure called with the discovered service details.
Source

pub async fn register<F>( &self, service_name: &str, parameters: OscRootNode, handler: F, ) -> Result<(), Error>
where F: Fn(OscPacket) + Send + 'static,

Registers a local OSC service to be discoverable by other clients.

§Arguments
  • service_name - The name of the service to register.
  • parameters - The OSC address space and parameters for this service.
  • handler - A function called when an OSC packet is received for this service.
Source

pub async fn unregister(&self, service_name: &str) -> Result<(), Error>

Unregisters an OSC service and stops its servers.

§Arguments
  • service_name - The name of the service to unregister.
Source

pub async fn send(&self, packet: OscPacket, to: &str) -> Result<(), Error>

Sends an OSC packet to services matching a name pattern.

§Arguments
  • packet - The OscPacket to send.
  • to - A pattern (e.g., “VRChat-Client-*”) to match against discovered service names.
Source

pub async fn send_to_addr( &self, packet: OscPacket, addr: SocketAddr, ) -> Result<(), Error>

Sends an OSC packet to a specific socket address.

§Arguments
  • packet - The OscPacket to send.
  • addr - The SocketAddr to send the packet to.
Source

pub async fn get_parameter( &self, method: &str, from: &str, ) -> Result<Vec<(Name, OscNode)>, Error>

Retrieves a specific parameter from services matching a name pattern.

§Arguments
  • method - The OSC path of the parameter (e.g., “/avatar/parameters/MyParam”).
  • from - A pattern (e.g., “VRChat-Client-*”) to match against discovered service names.
§Returns

A list of matching service names and their corresponding parameter values.

Source

pub async fn get_parameter_from_addr( &self, method: &str, addr: SocketAddr, ) -> Result<OscNode, Error>

Retrieves a specific parameter from a specific service address.

§Arguments
  • method - The OSC path of the parameter (e.g., “/avatar/parameters/MyParam”).
  • addr - The address of the service.
§Returns

The fetched parameter value.

Source

pub async fn shutdown(&self) -> Result<(), Error>

Shuts down all registered services and cleans up resources. This method should be called before the VRChatOSC instance is dropped to ensure graceful shutdown of asynchronous tasks and network services.

Source

pub async fn list_services(&self) -> Vec<String>

Lists the names of all currently registered services.

Trait Implementations§

Source§

impl Drop for VRChatOSC

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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, 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<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,