Crate xmtp_common

Crate xmtp_common 

Source
Expand description

Common types shared among all XMTP Crates

Re-exports§

pub use retry::*;
pub use wasm::*;
pub use stream_handles::*;
pub use const::*;
pub use logging::*;

Modules§

const
fmt
hex
logging
retry
A retry strategy that works with rusts native std::error::Error type.
snippet
stream_handles
Consistent Stream behavior between WebAssembly and Native utilizing tokio::task::spawn in native and wasm_bindgen_futures::spawn for web.
time
Time primitives for native and WebAssembly
traced_test
types
Common Primitive Types that may be shared across all XMTP Crates Types should not have any dependencies other than std and std-adjacent crates (like bytes)
wasm

Macros§

assert_err
wrapper over assert!(matches!()) for Errors assert_err!(fun(), StorageError::Explosion)
assert_logged
macro that can assert logs in tests. Note: tests that use this must be used in traced_test function and only with tokio’s current runtime.
assert_ok
wrapper over assert! macros for Ok’s
if_d14n
Convenience macro to easily export items for d14n
if_dev
Feature flag for dev network
if_local
if_native
Convenience macro to easily export items for native
if_not_test
if_only_test
if_test
if_v3
Convenience macro to easily export items for d14n
if_wasm
Convenience macro to easily export items for wasm
log_event
optify
Turn the Result<T, E> into an Option<T>, logging the error with tracing::error and returning None if the value matches on Result::Err(). Optionally pass a message as the second argument.
retry_async
Retry but for an async context
retryable
traced_test
wasm_or_native
wasm_or_native_expr
Convenience macro to easily evaluate an expression for wasm or native

Structs§

EventMetadata
Metadata about a log event variant, including its doc comment and required context fields. This struct is used by proc macros to access event metadata at compile time.
FakeMlsApplicationMessage
FakeMlsCommitMessage
a fake mls commit message populated with garbage data can be transformed into MlsMessageOut/ProtocolMessage
TestLogReplace
Replace inbox id in Contextual output with a name (i.e Alix, Bo, etc.)
TestWriter
Thread local writer which stores logs in memory

Enums§

Event

Traits§

DebugDisplay
Extension trait for formatting collections of Debug items in tests
Generate
Sha2Digest
Convenience wrapper trait covering functionality of cryptographic hash functions with fixed output size.

Functions§

is_structured_logging
Returns true if structured (JSON) logging is enabled. When true, context should not be embedded in the message to avoid duplication. Initializes from environment on first call, then caches the result.
logger
A simple test logger that defaults to the INFO level
logger_layer
rand_account_address
rand_array
rand_hexstring
rand_i64
rand_secret
rand_string
rand_time
rand_u64
rand_vec
rng
seeded_rng
sha256_bytes
Sha256 is used in places where cryptographic security is not required, as sha256 has a significant speed improvement over Keccak.
subscriber
tmp_path
toxiproxy_test
wait_for_eq
wait_for_ge
wait_for_ok
wait_for_some

Type Aliases§

Sha256Digest
SHA-256 hasher.

Attribute Macros§

async_trait
A proc macro attribute that wraps the input in an async_trait implementation, delegating to the appropriate async_trait implementation based on the target architecture.
test
A test macro that delegates to the appropriate test framework based on the target architecture.