Struct simple_pub_sub::client::Client
source · pub struct Client {
pub server: String,
pub port: u16,
/* private fields */
}Fields§
§server: String§port: u16Implementations§
source§impl Client
impl Client
sourcepub fn new(server: String, port: u16) -> Client
pub fn new(server: String, port: u16) -> Client
Examples found in repository?
More examples
examples/publish.rs (line 4)
2 3 4 5 6 7 8 9 10 11 12 13 14 15
async fn main() -> Result<(), String> {
// initialize the client.
let mut client = simple_pub_sub::client::Client::new("localhost".to_string(), 6480);
// connect the client.
let _ = client.connect().await;
// subscribe to the given topic.
let _ = client
.publish(
"abc".to_string(),
"test message".to_string().into_bytes().to_vec(),
)
.await;
Ok(())
}sourcepub async fn connect(&mut self) -> Result<(), Error>
pub async fn connect(&mut self) -> Result<(), Error>
Examples found in repository?
More examples
examples/publish.rs (line 6)
2 3 4 5 6 7 8 9 10 11 12 13 14 15
async fn main() -> Result<(), String> {
// initialize the client.
let mut client = simple_pub_sub::client::Client::new("localhost".to_string(), 6480);
// connect the client.
let _ = client.connect().await;
// subscribe to the given topic.
let _ = client
.publish(
"abc".to_string(),
"test message".to_string().into_bytes().to_vec(),
)
.await;
Ok(())
}pub async fn post(self, msg: Msg) -> Result<Vec<u8>, Error>
sourcepub async fn publish(self, topic: String, message: Vec<u8>) -> Result<(), Error>
pub async fn publish(self, topic: String, message: Vec<u8>) -> Result<(), Error>
Examples found in repository?
examples/publish.rs (lines 9-12)
2 3 4 5 6 7 8 9 10 11 12 13 14 15
async fn main() -> Result<(), String> {
// initialize the client.
let mut client = simple_pub_sub::client::Client::new("localhost".to_string(), 6480);
// connect the client.
let _ = client.connect().await;
// subscribe to the given topic.
let _ = client
.publish(
"abc".to_string(),
"test message".to_string().into_bytes().to_vec(),
)
.await;
Ok(())
}pub async fn query(self, topic: String) -> Result<String, Error>
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Client
impl RefUnwindSafe for Client
impl Send for Client
impl Sync for Client
impl Unpin for Client
impl UnwindSafe for Client
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more