Expand description
Common types shared among all XMTP Crates
Re-exports§
pub use retry::*;pub use wasm::*;pub use stream_handles::*;pub use const::*;
Modules§
- const
- fmt
- hex
- retry
- A retry strategy that works with rusts native
std::error::Errortype. - snippet
- stream_
handles - Consistent Stream behavior between WebAssembly and Native utilizing
tokio::task::spawnin native andwasm_bindgen_futures::spawnfor web. - time
- Time primitives for native and WebAssembly
- 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§
- 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 anOption<T>, logging the error withtracing::errorand returningNoneif the value matches on Result::Err(). Optionally pass a message as the second argument. - retry_
async - Retry but for an async context
- retryable
- wasm_
or_ native - wasm_
or_ native_ expr - Convenience macro to easily evaluate an expression for wasm or native
Structs§
- Event
Metadata - 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.
Enums§
Traits§
- Error
Code - A trait for errors that have a unique, stable error code.
- Sha2
Digest - 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.
- rand_
array - rand_
secret - rand_
string - rand_
vec - rng
- seeded_
rng - sha256_
array - Compute the SHA-256 hash of
bytesand return it as a fixed[u8; 32], avoiding the heap allocation done bysha256_bytes. - sha256_
bytes - Sha256 is used in places where cryptographic security is not required, as sha256 has a significant speed improvement over Keccak.
Type Aliases§
- Sha256
Digest - SHA-256 hasher.
Attribute Macros§
- async_
trait - A proc macro attribute that wraps the input in an
async_traitimplementation, delegating to the appropriateasync_traitimplementation based on the target architecture. - db_span
- Instrument an
xmtp_dbquery method asoperation = "db.<fn_name>"in libxmtp’s canonical, OTEL-safe span form (err, skip_all). Surfaces asxmtp.db.*Collector metrics. See [span] for the shared rationale. - err_
span - Error-case-only tracing for an FFI-exported fn:
#[tracing::instrument(level = "trace", skip_all, err)]. - mls_
span - Instrument a high-level MLS operation as
operation = "mls.<fn_name>"in libxmtp’s canonical, OTEL-safe span form (err, skip_all). Surfaces asxmtp.mls.*Collector metrics. See [span] for the shared rationale. - rpc_
span - Instrument an
ApiClientWrapperRPC method asoperation = "rpc.<fn_name>"in libxmtp’s canonical, OTEL-safe span form (err, skip_all). Surfaces asxmtp.api.*Collector metrics. See [span] for the shared rationale. - span
- Instrument a method as a telemetry operation span in libxmtp’s single
canonical, OTEL-safe form:
#[tracing::instrument(err, skip_all, fields(operation = "<prefix>.<fn_name>"))]. - timeout
- Attribute macro that wraps an async test body with a WASM-compatible timeout.
Derive Macros§
- Error
Code - Derive macro for the
ErrorCodetrait.