pub struct Client {
pub server: String,
pub http: Client,
}Fields§
§server: String§http: ClientImplementations§
Source§impl Client
impl Client
Sourcepub async fn get_pubkey(&self, id: &ThreemaID) -> Result<PublicKey>
pub async fn get_pubkey(&self, id: &ThreemaID) -> Result<PublicKey>
Examples found in repository?
More examples
examples/chatwith.rs (line 79)
70async fn main(){
71 env_logger::init();
72 let argv: Vec<_> = std::env::args().collect();
73 if argv.len() != 3 {
74 eprintln!("usage: {} CREDENTIALS-FILE CONTACT", argv[0]);
75 std::process::exit(1);
76 }
77 let creds = threema_client::import::json_file::from_file(&argv[1]).expect("could not read credentials json");
78 let contact = ThreemaID::try_from(argv[2].as_str()).expect("invalid ID");
79 let contact_pubkey = directory_api::Client::default().get_pubkey(&contact).await.expect("could not get public key");
80 let peer = threema_client::Peer{id: contact, pk: contact_pubkey};
81
82 let server = ThreemaServer {addr: SERVER.to_string(), pk: naclbox::PublicKey::from_slice(b"E\x0b\x97W5'\x9f\xde\xcb3\x13d\x8f_\xc6\xee\x9f\xf46\x0e\xa9*\x8c\x17Q\xc6a\xe4\xc0\xd8\xc9\t").unwrap()};
83 let messenger = Arc::new(messaging_client::Client::new(server, creds.clone()));
84
85 let recver = tokio::spawn(recv_print(Arc::clone(&messenger), peer.clone(), creds.clone()));
86 let mut stdin = tokio::io::BufReader::new(tokio::io::stdin());
87 loop {
88 let mut line = String::new();
89 match stdin.read_line(&mut line).await {
90 Err(e) => {
91 eprintln!("{}", e);
92 break;
93 }
94 Ok(0) => { break; }
95 Ok(_) => {
96 let mut plain = threema_client::msg_types::TEXT.to_le_bytes().to_vec();
97 plain.extend_from_slice(&line.trim_end().as_bytes());
98 let m = threema_client::transport::BoxedMessage::encrypt(&creds, "hi", &peer, plain, 0);
99 let sent = messenger.send_message(m).await;
100 if let Err(c) = sent {
101 println!("{:?}", c);
102 break;
103 }
104 }
105 }
106 }
107 messenger.shutdown();
108 eprintln!("waiting for receiver to quit...");
109 recver.await.unwrap();
110}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