Skip to main content

ComponentMut

Struct ComponentMut 

Source
pub struct ComponentMut<'a> { /* private fields */ }
Expand description

A mutable component in an ICE Stream

Implementations§

Source§

impl<'a> ComponentMut<'a>

Source

pub fn gather_candidates( &mut self, sockets: &[(TransportType, SocketAddr)], stun_servers: &[(TransportType, SocketAddr)], turn_servers: &[(SocketAddr, &TurnConfig)], ) -> Result<(), AgentError>

Start gathering candidates for this component. The parent Agent::poll is used to progress the gathering.

Candidates will be generated as follows (if they succeed):

  1. A host candidate for each sockets[i]. If TCP, then both an active and passive host candidate will be generated.
  2. For each sockets[i] a reflexive candidate for each stun_server[i] if different from any other candidate produced. The local address for each STUN server connection will be one of the entries provided in sockets.
  3. For each turn_servers[i] a TURN allocation will be attempted and a relayed candidate produced on success. If you would like multiple options for relayed candidates, e.g. UDP, TCP, TCP/TLS, then provide each option as different entries in the provided slice. The SocketAddr for each TURN server is the local address to communicate with the TURN server and should be different than any value provided through sockets.
Source

pub fn set_selected_pair( &mut self, selected: CandidatePair, ) -> Result<(), AgentError>

Set the pair that will be used to send/receive data. This will override the ICE negotiation chosen value.

Source

pub fn send<T: AsRef<[u8]> + Debug>( &mut self, data: T, now: Instant, ) -> Result<Transmit<Box<[u8]>>, AgentError>

Send data to the peer using the selected pair. This will not succeed until the Component has reached ComponentConnectionState::Connected

Methods from Deref<Target = Component<'a>>§

Source

pub fn id(&self) -> usize

The component identifier within a particular ICE Stream

Source

pub fn stream(&self) -> Stream<'a>

Retrieve the Stream for this component.

§Examples
let mut agent = Agent::default();
let stream_id = agent.add_stream();
let mut stream = agent.mut_stream(stream_id).unwrap();
let component_id = stream.add_component().unwrap();
let component = stream.component(component_id).unwrap();
assert_eq!(component.stream().id(), stream_id);
Source

pub fn state(&self) -> ComponentConnectionState

Retrieve the current state of a Component

§Examples

The initial state is ComponentState::New

let mut agent = Agent::default();
let stream_id = agent.add_stream();
let mut stream = agent.mut_stream(stream_id).unwrap();
let component_id = stream.add_component().unwrap();
let component = stream.component(component_id).unwrap();
assert_eq!(component.state(), ComponentConnectionState::New);
Source

pub fn selected_pair(&self) -> Option<&CandidatePair>

The CandidatePair this component has selected to send/receive data with. This will not be valid until the Component has reached ComponentConnectionState::Connected

Trait Implementations§

Source§

impl<'a> Debug for ComponentMut<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Deref for ComponentMut<'a>

Source§

type Target = Component<'a>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for ComponentMut<'a>

§

impl<'a> !UnwindSafe for ComponentMut<'a>

§

impl<'a> Freeze for ComponentMut<'a>

§

impl<'a> Send for ComponentMut<'a>

§

impl<'a> Sync for ComponentMut<'a>

§

impl<'a> Unpin for ComponentMut<'a>

§

impl<'a> UnsafeUnpin for ComponentMut<'a>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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<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