Struct threema_gateway::E2eApi [−][src]
Struct to talk to the E2E API (with end-to-end encryption).
Implementations
impl E2eApi
[src]
pub fn encrypt_raw(
&self,
data: &[u8],
recipient_key: &RecipientKey
) -> EncryptedMessage
[src]
&self,
data: &[u8],
recipient_key: &RecipientKey
) -> EncryptedMessage
Encrypt raw bytes for the specified recipient public key.
pub fn encrypt_text_msg(
&self,
text: &str,
recipient_key: &RecipientKey
) -> EncryptedMessage
[src]
&self,
text: &str,
recipient_key: &RecipientKey
) -> EncryptedMessage
Encrypt a text message for the specified recipient public key.
pub fn encrypt_image_msg(
&self,
blob_id: &BlobId,
img_size_bytes: u32,
image_data_nonce: &[u8; 24],
recipient_key: &RecipientKey
) -> EncryptedMessage
[src]
&self,
blob_id: &BlobId,
img_size_bytes: u32,
image_data_nonce: &[u8; 24],
recipient_key: &RecipientKey
) -> EncryptedMessage
Encrypt an image message for the specified recipient public key.
Before calling this function, you need to encrypt the image data (JPEG
format) with encrypt_raw
and
upload the ciphertext to the blob server.
The image size needs to be specified in bytes. Note that the size is only used for download size displaying purposes and has no security implications.
pub fn encrypt_file_msg(
&self,
msg: &FileMessage,
recipient_key: &RecipientKey
) -> EncryptedMessage
[src]
&self,
msg: &FileMessage,
recipient_key: &RecipientKey
) -> EncryptedMessage
Encrypt a file message for the specified recipient public key.
To construct a FileMessage
, use FileMessageBuilder
.
pub async fn send(
&self,
to: &str,
message: &EncryptedMessage,
delivery_receipts: bool
) -> Result<String, ApiError>
[src]
&self,
to: &str,
message: &EncryptedMessage,
delivery_receipts: bool
) -> Result<String, ApiError>
Send an encrypted E2E message to the specified Threema ID.
If delivery_receipts
is set to false
, then the recipient’s device will
be instructed not to send any delivery receipts. This can be useful for
one-way communication where the delivery receipt will be discarded. If
you’re unsure what value to use, set the flag to false
.
Cost: 1 credit.
pub async fn lookup_pubkey(&self, id: &str) -> Result<PublicKey, ApiError>
[src]
Fetch the public key for the specified Threema ID.
For the end-to-end encrypted mode, you need the public key of the recipient in order to encrypt a message. While it’s best to obtain this directly from the recipient (extract it from the QR code), this may not be convenient, and therefore you can also look up the key associated with a given ID from the server.
It is strongly recommended that you cache the public keys to avoid querying the API for each message.
pub async fn lookup_id(
&self,
criterion: &LookupCriterion
) -> Result<String, ApiError>
[src]
&self,
criterion: &LookupCriterion
) -> Result<String, ApiError>
Look up a Threema ID in the directory.
An ID can be looked up either by a phone number or an e-mail
address, in plaintext or hashed form. You can specify one of those
criteria using the LookupCriterion
enum.
pub async fn lookup_capabilities(
&self,
id: &str
) -> Result<Capabilities, ApiError>
[src]
&self,
id: &str
) -> Result<Capabilities, ApiError>
Look up the capabilities of a certain Threema ID.
Before you send a file to a Threema ID using the blob upload (+file message), you may want to check whether the recipient uses a Threema version that supports receiving files. The receiver may be using an old version, or a platform where file reception is not supported.
pub async fn lookup_credits(&self) -> Result<i64, ApiError>
[src]
Look up a remaining gateway credits.
pub async fn blob_upload(
&self,
data: &EncryptedMessage,
persist: bool
) -> Result<BlobId, ApiError>
[src]
&self,
data: &EncryptedMessage,
persist: bool
) -> Result<BlobId, ApiError>
Upload encrypted data to the blob server.
If persist
is set to true
, then the blob will not be deleted
after a client has downloaded it and marked it as done. Use when
distributing the same blob to multiple clients.
Cost: 1 credit.
pub async fn blob_upload_raw(
&self,
data: &[u8],
persist: bool
) -> Result<BlobId, ApiError>
[src]
&self,
data: &[u8],
persist: bool
) -> Result<BlobId, ApiError>
Upload raw data to the blob server.
If persist
is set to true
, then the blob will not be deleted
after a client has downloaded it and marked it as done. Use when
distributing the same blob to multiple clients.
Cost: 1 credit.
pub fn decode_incoming_message(
&self,
bytes: impl AsRef<[u8]>
) -> Result<IncomingMessage, ApiError>
[src]
&self,
bytes: impl AsRef<[u8]>
) -> Result<IncomingMessage, ApiError>
Deserialize an incoming Threema Gateway message in
application/x-www-form-urlencoded
format.
This will validate the MAC. If the MAC is invalid,
ApiError::InvalidMac
will be returned.
pub fn decrypt_incoming_message(
&self,
message: &IncomingMessage,
public_key: &PublicKey
) -> Result<Vec<u8>, CryptoError>
[src]
&self,
message: &IncomingMessage,
public_key: &PublicKey
) -> Result<Vec<u8>, CryptoError>
Decrypt an IncomingMessage
using the provided public key and our
own private key.
Trait Implementations
Auto Trait Implementations
impl !RefUnwindSafe for E2eApi
impl Send for E2eApi
impl Sync for E2eApi
impl Unpin for E2eApi
impl !UnwindSafe for E2eApi
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T> Instrument for T
[src]
pub fn instrument(self, span: Span) -> Instrumented<Self>
[src]
pub fn in_current_span(self) -> Instrumented<Self>
[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.
pub fn to_owned(&self) -> T
[src]
pub 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.
pub 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>,