Skip to main content

Creating Associations

You can create associations on a MasterChannel by specifying configuration and callback interfaces.

let mut association = channel
.add_association(
EndpointAddress::try_new(1024)?,
get_association_config(),
ExampleReadHandler::boxed(),
Box::new(ExampleAssociationHandler),
Box::new(ExampleAssociationInformation),
)
.await?;
note

The Rust API and the binding APIs handle associations in two different ways:

  • Bindings return an association token to use on the channel.
  • Rust API returns an object that has its own methods for performing operations on the association.

The AssociationId struct that is returned when adding an association is just a token. While it's required to perform operations on a particular outstation on the channel, you don't need to keep a reference to it unless you need it to perform operations later. Allowing the AssociationId to be garbage collected won't remove the association from the channel.

Removing

Remove associations from a channel by calling MasterChannel.removeAssociation and passing in the AssociationId. Doing so will stop all operations for that association.