[−][src]Struct pubnub_core::PubNub
PubNub Client
The PubNub lib implements socket pools to relay data requests as a client connection to the PubNub Network.
Methods
impl<TTransport, TRuntime> PubNub<TTransport, TRuntime> where
TTransport: Transport + 'static,
TRuntime: Runtime + 'static,
[src]
TTransport: Transport + 'static,
TRuntime: Runtime + 'static,
pub async fn publish<'_>(
&'_ self,
channel: Name,
message: Object
) -> Result<Timetoken, <TTransport as Transport>::Error>
[src]
&'_ self,
channel: Name,
message: Object
) -> Result<Timetoken, <TTransport as Transport>::Error>
Publish a message over the PubNub network.
Errors
Returns transport-specific errors.
Example
use pubnub_core::{data::channel, json::object, Builder}; let pubnub = Builder::with_components(transport, runtime).build(); let channel_name: channel::Name = "my-channel".parse().unwrap(); let timetoken = pubnub .publish( channel_name, object! { "username" => "JoeBob", "content" => "Hello, world!", }, ) .await?; println!("Timetoken: {}", timetoken);
pub async fn publish_with_metadata<'_>(
&'_ self,
channel: Name,
message: Object,
metadata: Object
) -> Result<Timetoken, <TTransport as Transport>::Error>
[src]
&'_ self,
channel: Name,
message: Object,
metadata: Object
) -> Result<Timetoken, <TTransport as Transport>::Error>
Publish a message over the PubNub network with an extra metadata payload.
Errors
Returns transport-specific errors.
Example
use pubnub_core::{data::channel, json::object, Builder}; let pubnub = Builder::with_components(transport, runtime).build(); let message = object! { "username" => "JoeBob", "content" => "Hello, world!", }; let metadata = object! { "uuid" => "JoeBob", }; let channel_name: channel::Name = "my-channel".parse().unwrap(); let timetoken = pubnub .publish_with_metadata(channel_name, message, metadata) .await?; println!("Timetoken: {}", timetoken);
impl<TTransport, TRuntime> PubNub<TTransport, TRuntime> where
TTransport: Transport + 'static,
TRuntime: Runtime + 'static,
[src]
TTransport: Transport + 'static,
TRuntime: Runtime + 'static,
pub async fn subscribe<'_>(
&'_ mut self,
channel: Name
) -> Subscription<TRuntime>
[src]
&'_ mut self,
channel: Name
) -> Subscription<TRuntime>
Subscribe to a message stream over the PubNub network.
The PubNub client only maintains a single subscribe loop for all subscription streams. This has a benefit that it optimizes for a low number of sockets to the PubNub network. It has a downside that requires all streams to consume faster than the subscribe loop produces. A slow consumer will create a head-of-line blocking bottleneck in the processing of received messages. All streams can only consume as fast as the slowest.
For example, with 3 total subscription streams and 1 that takes 30 seconds to process each message; the other 2 streams will be blocked waiting for that 30-second duration on the slow consumer.
Example
use futures_util::stream::StreamExt; use pubnub_core::{data::channel, json::object, Builder}; let mut pubnub = Builder::with_components(transport, runtime).build(); let channel_name: channel::Name = "my-channel".parse().unwrap(); let mut stream = pubnub.subscribe(channel_name).await; while let Some(message) = stream.next().await { println!("Received message: {:?}", message); }
impl<TTransport, TRuntime> PubNub<TTransport, TRuntime> where
TTransport: Transport + 'static,
TRuntime: Runtime + 'static,
[src]
TTransport: Transport + 'static,
TRuntime: Runtime + 'static,
pub fn transport(&self) -> &TTransport
[src]
Get a reference to a transport being used.
pub fn runtime(&self) -> &TRuntime
[src]
Get a reference to a runtime being used.
impl<TTransport, TRuntime> PubNub<TTransport, TRuntime> where
TTransport: Transport + 'static,
TRuntime: Runtime + 'static,
[src]
TTransport: Transport + 'static,
TRuntime: Runtime + 'static,
pub async fn call<'_, TRequest>(
&'_ self,
req: TRequest
) -> Result<<TTransport as Service<TRequest>>::Response, <TTransport as Service<TRequest>>::Error> where
TTransport: Service<TRequest>,
[src]
&'_ self,
req: TRequest
) -> Result<<TTransport as Service<TRequest>>::Response, <TTransport as Service<TRequest>>::Error> where
TTransport: Service<TRequest>,
Trait Implementations
impl<TTransport: Clone, TRuntime: Clone> Clone for PubNub<TTransport, TRuntime> where
TTransport: Transport,
TRuntime: Runtime,
[src]
TTransport: Transport,
TRuntime: Runtime,
fn clone(&self) -> PubNub<TTransport, TRuntime>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<TTransport: Debug, TRuntime: Debug> Debug for PubNub<TTransport, TRuntime> where
TTransport: Transport,
TRuntime: Runtime,
[src]
TTransport: Transport,
TRuntime: Runtime,
Auto Trait Implementations
impl<TTransport, TRuntime> !RefUnwindSafe for PubNub<TTransport, TRuntime>
impl<TTransport, TRuntime> Send for PubNub<TTransport, TRuntime>
impl<TTransport, TRuntime> Sync for PubNub<TTransport, TRuntime>
impl<TTransport, TRuntime> Unpin for PubNub<TTransport, TRuntime> where
TTransport: Unpin,
TTransport: Unpin,
impl<TTransport, TRuntime> !UnwindSafe for PubNub<TTransport, TRuntime>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Any for T where
T: Any + ?Sized,
T: Any + ?Sized,
fn type_id_compat(&self) -> TypeId
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error
The type returned in the event of a conversion error.
fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>
[src]
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
V: MultiLane<T>,