Struct VRChatOSC

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

Main struct for managing VRChat OSC services, discovery, and communication.

Implementations§

Source§

impl VRChatOSC

Source

pub async fn new() -> Result<Arc<VRChatOSC>, Error>

Creates a new VRChatOSC instance. Initializes mDNS, sets up service discovery, and starts a listener task for mDNS service notifications.

Source

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

Registers a callback function to be invoked when an mDNS service is discovered.

§Arguments
  • callback - A function or closure that takes the service Name and SocketAddr as arguments. It must be Send + Sync + 'static.
Source

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

Registers a new OSC service with the local mDNS daemon and starts listening for OSC messages.

§Arguments
  • service_name - The name of the service to register (e.g., “MyAppOSC”).
  • parameters - The root node of the OSC address space for this service.
  • handler - A function that will be called when an OSC packet is received for this service. It must be Fn(OscPacket) + Send + 'static.
Source

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

Unregisters an OSC service. Stops the OSC and OSCQuery servers and removes mDNS announcements.

§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 given pattern.

§Arguments
  • packet - The OscPacket to send.
  • to - A glob pattern (e.g., “VRChat-Client-*”) to match against service names. This matches against the service instance name found via mDNS.
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 OSC parameter (node) from services matching a pattern.

§Arguments
  • method - The OSC path of the parameter to fetch (e.g., “/avatar/parameters/SomeParam”).
  • from - A glob pattern (e.g., “VRChat-Client-*”) to match against service names. This matches against the service instance name found via mDNS.
§Returns

A Vec of tuples, where each tuple contains the service Name and the fetched OscNode. Returns an empty Vec if no services match or if fetching fails for all matched services.

Source

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

Retrieves a specific OSC parameter (node) from a specific OSCQuery service address.

§Arguments
  • method - The OSC path of the parameter to fetch (e.g., “/avatar/parameters/SomeParam”).
  • addr - The SocketAddr of the OSCQuery service.
§Returns

The fetched OscNode.

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.

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<T> ErasedDestructor for T
where T: 'static,

Source§

impl<A, B, T> HttpServerConnExec<A, B> for T
where B: Body,