This commit is contained in:
mfahampshire
2024-10-09 16:35:23 +02:00
parent 77dd52074e
commit 0be3f3159e
2 changed files with 20 additions and 10 deletions
@@ -1,11 +1,5 @@
import { Callout } from 'nextra/components'
# Mixnet Module
This module exposes the logic of creating and interacting with clients and Mixnet messages. This is recommended for those wanting to either start playing around with the Mixnet and how it works, or build connection logic.
<Callout type="info" emoji="️">
For developers wanting something more 'plug and play' we recommend the [`TcpProxy` module](./tcpproxy).
</Callout>
> For developers wanting something more 'plug and play' we recommend the [`TcpProxy` module](./tcpproxy).
@@ -1,4 +1,20 @@
# Message Types
There are two methods for sending messages through the mixnet using your client:
* `send_plain_message()` is the most simple: pass the recipient address and the message you wish to send as a string (this was previously `send_str()`). This is a nicer-to-use wrapper around `send_message()` which
* `send_message()` allows you to also define the amount of SURBs to send along with your message (which is sent as bytes).
There are several functions used to send outgoing messages through the Mixnet, each with a different level of customisation:
- `send(&self, message: InputMessage) -> Result<()>`
Sends a `InputMessage` to the mixnet. This is the most low-level sending function, for full customization. Called by `send_message()`.
- `send_message<M>(&self, address: Recipient, message: M, surbs: IncludedSurbs) -> Result<()>`
Sends bytes to the supplied Nym address. There is the option to specify the number of reply-SURBs to include. Called by `send_plain_message()`.
- `send_plain_message<M>(&self, address: Recipient, message: M) -> Result<()>`
Sends data to the supplied Nym address with the default surb behaviour.
> Note we specify *outgoing* messages above: this is because the SDK assumes that replies will be anonymous via [SURBs]() TODO LINK.
Replies rely on the creation of an `AnonymousSenderTag` by parsing and storing the `sender_tag` from incoming messages, and using this to reply, instead of the `Receipient` type used by the functions outlined above:
`send_reply<M>(&self, recipient_tag: AnonymousSenderTag, message: M) -> Result<()>` will send the reply message to the supplied anonymous recipient.
> You can find all of the function definitions [here](https://github.com/nymtech/nym/blob/master/sdk/rust/nym-sdk/src/mixnet/traits.rs).