Skip to main content

Config

Struct Config 

Source
pub struct Config { /* private fields */ }

Implementations§

Source§

impl Config

Source

pub fn new(path: &str, name: &str) -> Self

path - /path/to/socket (must end with .sock .socket or .ipc) or host:port for websockets use ws://host[:port] or wss://host[:port]

name - an unique client name

Examples found in repository?
examples/client_listener.rs (line 10)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let name = "test.client.listener";
9    // create a new client instance
10    let config = Config::new("/tmp/busrt.sock", name);
11    let mut client = Client::connect(&config).await?;
12    // subscribe to all topics
13    let opc = client.subscribe("#", QoS::Processed).await?.expect("no op");
14    opc.await??;
15    // handle incoming frames
16    let rx = client.take_event_channel().unwrap();
17    while let Ok(frame) = rx.recv().await {
18        println!(
19            "Frame from {}: {:?} {:?} {}",
20            frame.sender(),
21            frame.kind(),
22            frame.topic(),
23            std::str::from_utf8(frame.payload()).unwrap_or("something unreadable")
24        );
25    }
26    Ok(())
27}
More examples
Hide additional examples
examples/client_sender.rs (line 10)
7async fn main() -> Result<(), Box<dyn std::error::Error>> {
8    let name = "test.client.sender";
9    // create a new client instance
10    let config = Config::new("/tmp/busrt.sock", name);
11    let mut client = Client::connect(&config).await?;
12    // publish to a topic
13    let opc = client
14        .publish("some/topic", "hello".as_bytes().into(), QoS::Processed)
15        .await?
16        .expect("no op");
17    opc.await??;
18    // send a direct message
19    let opc = client
20        .send(
21            "test.client.listener",
22            "hello".as_bytes().into(),
23            QoS::Processed,
24        )
25        .await?
26        .expect("no op");
27    opc.await??;
28    // send a broadcast message
29    let opc = client
30        .send_broadcast("test.*", "hello everyone".as_bytes().into(), QoS::Processed)
31        .await?
32        .expect("no op");
33    opc.await??;
34    Ok(())
35}
Source

pub fn buf_size(self, size: usize) -> Self

Source

pub fn buf_ttl(self, ttl: Duration) -> Self

Source

pub fn queue_size(self, size: usize) -> Self

Source

pub fn timeout(self, timeout: Duration) -> Self

Source

pub fn token<S: AsRef<str>>(self, token: S) -> Self

Bearer token for authorization header if required

Trait Implementations§

Source§

impl Clone for Config

Source§

fn clone(&self) -> Config

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Config

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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