Skip to content

Commit

Permalink
Add "receive" Cargo feature
Browse files Browse the repository at this point in the history
  • Loading branch information
dbrgn committed Apr 1, 2021
1 parent c6b5200 commit 1c67b76
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ references:
command: |
export PKG_CONFIG_PATH=/opt/libsodium/lib/pkgconfig:$PKG_CONFIG_PATH
export LD_LIBRARY_PATH=/opt/libsodium/lib:$LD_LIBRARY_PATH
cargo update && cargo build && cargo test
cargo update && cargo build --all-targets && cargo build --all-targets --all-features && cargo test --all-features
- save_cache:
key: v3-{{ .Environment.CIRCLE_JOB }}-cargo-cache-{{ checksum "Cargo.toml" }}
paths:
Expand Down
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@ include = [
edition = "2018"

[features]
dev = []
default = ["receive"]
receive = ["serde_urlencoded"] # Support for receiving and decrypting incoming messages

[dependencies]
byteorder = "1.0"
Expand All @@ -30,7 +31,7 @@ thiserror = "1"
reqwest = { version = "0.11", features = ["rustls-tls-native-roots", "multipart"], default-features = false }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_urlencoded = "0.7"
serde_urlencoded = { version = "0.7", optional = true }
sodiumoxide = "0.2.0"

[dev-dependencies]
Expand Down
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ Look up Threema ID by email hash:
cargo run --example lookup_id -- by_email_hash <from> <secret> 1ea093239cc5f0e1b6ec81b866265b921f26dc4033025410063309f4d1a8ee2c


## Cargo Features

This library offers the following optional features:

- `receive`: Add support for processing incoming messages. Enabled by default.


## Rust Version Requirements (MSRV)

This library generally tracks the latest stable Rust version but tries to
Expand Down
5 changes: 4 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ mod connection;
mod crypto;
pub mod errors;
mod lookup;
#[cfg(feature = "receive")]
mod receive;
mod types;

Expand All @@ -93,10 +94,12 @@ pub use crate::{
connection::Recipient,
crypto::{encrypt_file_data, EncryptedMessage, RecipientKey},
lookup::{Capabilities, LookupCriterion},
receive::IncomingMessage,
types::{BlobId, FileMessage, FileMessageBuilder, MessageType, RenderingType},
};

#[cfg(feature = "receive")]
pub use crate::receive::IncomingMessage;

const MSGAPI_URL: &str = "https://msgapi.threema.ch";

#[cfg(test)]
Expand Down

0 comments on commit 1c67b76

Please sign in to comment.