pub struct Tx3ClientBuilder { /* private fields */ }Expand description
Builder for Tx3Client.
Obtained via Protocol::client. All fallible validation — verifying
that the selected profile exists, that every bound party is declared by
the protocol — happens in Tx3ClientBuilder::build. Setters never
return Result, so chains stay fluent.
§Example
use tx3_sdk::tii::Protocol;
use tx3_sdk::{Party};
let client = Protocol::from_file("protocol.tii")?
.client()
.trp_endpoint("https://trp.example")
.with_profile("preprod")
.with_party("sender", Party::address("addr_test1..."))
.build()?;Implementations§
Source§impl Tx3ClientBuilder
impl Tx3ClientBuilder
Sourcepub fn from_parts(
transactions: HashMap<String, TirEnvelope>,
profiles: HashMap<String, Profile>,
known_parties: HashSet<String>,
) -> Self
pub fn from_parts( transactions: HashMap<String, TirEnvelope>, profiles: HashMap<String, Profile>, known_parties: HashSet<String>, ) -> Self
Seeds a builder with already-deconstructed protocol fragments. This is the entry point used by codegen-generated bindings, which embed only the runtime essentials at codegen time (per-tx TIR envelopes, per-profile environment + party-address maps, declared party names) and avoid carrying the rest of the TII document into the generated crate.
Sourcepub fn trp(self, opts: ClientOptions) -> Self
pub fn trp(self, opts: ClientOptions) -> Self
Sets the full TRP client options.
Sourcepub fn trp_endpoint(self, url: impl Into<String>) -> Self
pub fn trp_endpoint(self, url: impl Into<String>) -> Self
Sets the TRP endpoint URL (no headers). Overwrites any previously supplied options.
Sourcepub fn with_header(
self,
key: impl Into<String>,
value: impl Into<String>,
) -> Self
pub fn with_header( self, key: impl Into<String>, value: impl Into<String>, ) -> Self
Adds a header to the TRP client. Initializes the TRP options to an
empty endpoint if not yet set — callers must still supply an endpoint
via Tx3ClientBuilder::trp or Tx3ClientBuilder::trp_endpoint.
Sourcepub fn with_profile(self, name: impl Into<String>) -> Self
pub fn with_profile(self, name: impl Into<String>) -> Self
Selects a profile by name. Validated in build().
Sourcepub fn with_party(self, name: impl Into<String>, party: Party) -> Self
pub fn with_party(self, name: impl Into<String>, party: Party) -> Self
Binds a party (signer or read-only address) by name. Validated in
build() against the protocol’s declared parties.
Sourcepub fn with_party_unchecked(self, name: impl Into<String>, party: Party) -> Self
pub fn with_party_unchecked(self, name: impl Into<String>, party: Party) -> Self
Binds a party without validating the name against the protocol’s declared parties. The entry is carried straight through to the built client.
Intended for codegen-generated wrappers, which materialize one typed
setter per declared party — the name is baked in at codegen time, so
runtime validation would always pass and the embedded party-name set
can be omitted. Hand-written code SHOULD use Tx3ClientBuilder::with_party.
Sourcepub fn with_parties<I, K>(self, parties: I) -> Self
pub fn with_parties<I, K>(self, parties: I) -> Self
Binds multiple parties at once.
Sourcepub fn with_env_value(
self,
key: impl Into<String>,
value: impl Into<Value>,
) -> Self
pub fn with_env_value( self, key: impl Into<String>, value: impl Into<Value>, ) -> Self
Sets a single environment value. Merged on top of the selected profile’s environment at resolve time (override wins).
Sourcepub fn build(self) -> Result<Tx3Client, Error>
pub fn build(self) -> Result<Tx3Client, Error>
Validates the builder state and materializes the Tx3Client.
§Errors
Error::Trpif no TRP endpoint was supplied.Error::UnknownProfileif the selected profile is not declared by the protocol.Error::UnknownPartyif any bound party is not declared by the protocol.