pub struct StreamMut<'a> { /* private fields */ }Expand description
A (mutable) ICE stream
Implementations§
Source§impl<'a> StreamMut<'a>
impl<'a> StreamMut<'a>
Sourcepub fn add_component(&mut self) -> Result<usize, AgentError>
pub fn add_component(&mut self) -> Result<usize, AgentError>
Add a Component to this stream.
§Examples
Add a Component
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.id(), component::RTP);Sourcepub fn mut_component(&mut self, index: usize) -> Option<ComponentMut<'_>>
pub fn mut_component(&mut self, index: usize) -> Option<ComponentMut<'_>>
Retrieve mutable access to a component in this stream. None will be returned if the
component does not exist
Sourcepub fn set_local_credentials(&mut self, credentials: Credentials)
pub fn set_local_credentials(&mut self, credentials: Credentials)
Set local ICE credentials for this Stream.
§Examples
let mut agent = Agent::default();
let stream_id = agent.add_stream();
let mut stream = agent.mut_stream(stream_id).unwrap();
let credentials = Credentials {ufrag: "1".to_owned(), passwd: "2".to_owned()};
stream.set_local_credentials(credentials);Sourcepub fn set_remote_credentials(&mut self, credentials: Credentials)
pub fn set_remote_credentials(&mut self, credentials: Credentials)
Set remote ICE credentials for this Stream.
§Examples
let mut agent = Agent::default();
let stream_id = agent.add_stream();
let mut stream = agent.mut_stream(stream_id).unwrap();
let credentials = Credentials {ufrag: "1".to_owned(), passwd: "2".to_owned()};
stream.set_remote_credentials(credentials);Sourcepub fn add_remote_candidate(&mut self, cand: Candidate)
pub fn add_remote_candidate(&mut self, cand: Candidate)
Add a remote candidate for connection checks for use with this stream
§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();
let addr = "127.0.0.1:9999".parse().unwrap();
let candidate = Candidate::builder(
0,
CandidateType::Host,
TransportType::Udp,
"0",
addr
)
.build();
stream.add_remote_candidate(candidate);Sourcepub fn handle_incoming_data<T: AsRef<[u8]> + Debug>(
&mut self,
component_id: usize,
transmit: Transmit<T>,
now: Instant,
) -> HandleRecvReply<T>
pub fn handle_incoming_data<T: AsRef<[u8]> + Debug>( &mut self, component_id: usize, transmit: Transmit<T>, now: Instant, ) -> HandleRecvReply<T>
Provide the stream with data that has been received on an external socket. The returned value indicates what has been done with the data and any application data that has been received.
Sourcepub fn poll_recv(&mut self) -> Option<PendingRecv>
pub fn poll_recv(&mut self) -> Option<PendingRecv>
Poll for any received data.
Must be called after handle_incoming_data if have_more_data is true.
Sourcepub fn end_of_remote_candidates(&mut self)
pub fn end_of_remote_candidates(&mut self)
Indicate that no more candidates are expected from the peer. This may allow the ICE process to complete.
Sourcepub fn allocated_socket(
&mut self,
component_id: usize,
transport: TransportType,
from: SocketAddr,
to: SocketAddr,
local_addr: Result<SocketAddr, StunError>,
now: Instant,
)
pub fn allocated_socket( &mut self, component_id: usize, transport: TransportType, from: SocketAddr, to: SocketAddr, local_addr: Result<SocketAddr, StunError>, now: Instant, )
Provide a reply to the
AgentPoll::AllocateSocket request. The
component_id, transport, from, and to values must match exactly with the request.
Sourcepub fn add_local_candidate(&mut self, candidate: Candidate) -> bool
pub fn add_local_candidate(&mut self, candidate: Candidate) -> bool
Add a local candidate for this stream.
Returns whether the candidate was added internally.
Sourcepub fn add_local_gathered_candidate(
&mut self,
candidate: GatheredCandidate,
) -> bool
pub fn add_local_gathered_candidate( &mut self, candidate: GatheredCandidate, ) -> bool
Add a local candidate for this stream.
Returns whether the candidate was added internally.
Sourcepub fn end_of_local_candidates(&mut self)
pub fn end_of_local_candidates(&mut self)
Signal the end of local candidates. Calling this function may allow ICE processing to complete.
Methods from Deref<Target = Stream<'a>>§
Sourcepub fn component(&self, index: usize) -> Option<Component<'_>>
pub fn component(&self, index: usize) -> Option<Component<'_>>
Retrieve a Component from this stream. If the index doesn’t exist or a component is not
available at that index, None is returned
§Examples
Remove a Component
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.id(), component::RTP);
assert!(stream.component(component::RTP).is_some());Retrieving a Component that doesn’t exist will return None
let mut agent = Agent::default();
let stream_id = agent.add_stream();
let stream = agent.stream(stream_id).unwrap();
assert!(stream.component(component::RTP).is_none());Sourcepub fn local_credentials(&self) -> Option<Credentials>
pub fn local_credentials(&self) -> Option<Credentials>
Retreive the previouly set local ICE credentials for this Stream.
§Examples
let mut agent = Agent::default();
let stream_id = agent.add_stream();
let mut stream = agent.mut_stream(stream_id).unwrap();
let credentials = Credentials {ufrag: "1".to_owned(), passwd: "2".to_owned()};
stream.set_local_credentials(credentials.clone());
assert_eq!(stream.local_credentials(), Some(credentials));Sourcepub fn remote_credentials(&self) -> Option<Credentials>
pub fn remote_credentials(&self) -> Option<Credentials>
Retreive the previouly set remote ICE credentials for this Stream.
§Examples
let mut agent = Agent::default();
let stream_id = agent.add_stream();
let mut stream = agent.mut_stream(stream_id).unwrap();
let credentials = Credentials {ufrag: "1".to_owned(), passwd: "2".to_owned()};
stream.set_remote_credentials(credentials.clone());
assert_eq!(stream.remote_credentials(), Some(credentials));Sourcepub fn local_candidates(&self) -> impl Iterator<Item = &Candidate> + '_
pub fn local_candidates(&self) -> impl Iterator<Item = &Candidate> + '_
Retrieve previously gathered local candidates
Sourcepub fn remote_candidates(&self) -> &[Candidate]
pub fn remote_candidates(&self) -> &[Candidate]
Retrieve previously set remote candidates for connection checks from this stream
§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();
let addr = "127.0.0.1:9999".parse().unwrap();
let candidate = Candidate::builder(
0,
CandidateType::Host,
TransportType::Udp,
"0",
addr
)
.build();
stream.add_remote_candidate(candidate.clone());
let remote_cands = stream.remote_candidates();
assert_eq!(remote_cands.len(), 1);
assert_eq!(remote_cands[0], candidate);Sourcepub fn component_ids_iter(&self) -> impl Iterator<Item = usize> + '_
pub fn component_ids_iter(&self) -> impl Iterator<Item = usize> + '_
Return an Iterator over all the component ids in this stream.