Skip to main content

Peer

Struct Peer 

Source
pub struct Peer<Msg>
where Msg: UserMsgPayload + 'static,
{ /* private fields */ }
Expand description

User-facing handle to a mesh peer running in the browser.

Implementations§

Source§

impl<Msg> Peer<Msg>
where Msg: UserMsgPayload + 'static,

Source

pub fn new() -> Self

Source

pub fn with_ice_servers(ice_servers: Vec<IceServerConfig>) -> Self

Source

pub fn with_storage(ice_servers: Vec<IceServerConfig>, storage: Storage) -> Self

Source

pub fn my_id(&self) -> PeerID

Source

pub fn subscribe(&self, subscription: Event<Msg>) -> u64

Source

pub fn unsubscribe(&self, id: u64) -> bool

Source

pub async fn start(&self) -> Result<String>

Source

pub async fn receive_offer(&self, offer: &str) -> Result<String>

Source

pub async fn receive_answer(&self, answer: &str) -> Result<()>

Source

pub fn send(&self, peer_id: PeerID, data: Msg)

Source

pub fn broadcast(&self, data: Msg)

Source

pub fn leave(&self)

Source

pub fn is_connected(&self, peer_id: PeerID) -> bool

Source

pub fn connected_peers(&self) -> HashSet<String>

Trait Implementations§

Source§

impl<Msg> Default for Peer<Msg>
where Msg: UserMsgPayload + 'static,

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<Msg> Drop for Peer<Msg>
where Msg: UserMsgPayload + 'static,

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

§

impl<Msg> Freeze for Peer<Msg>

§

impl<Msg> !RefUnwindSafe for Peer<Msg>

§

impl<Msg> !Send for Peer<Msg>

§

impl<Msg> !Sync for Peer<Msg>

§

impl<Msg> Unpin for Peer<Msg>

§

impl<Msg> UnsafeUnpin for Peer<Msg>

§

impl<Msg> !UnwindSafe for Peer<Msg>

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, 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> 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<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Source§

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Source§

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V