1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123
//! The Messages specific to the Service Protocol, as described in //! [Section 5.4](https://melt-umn.github.io/monto-v3-draft/draft02/#5-4-service-protocol-messages) //! of the specification. use std::collections::BTreeSet; use common::messages::{Product, ProductDescriptor, ProductIdentifier, ProtocolVersion, SoftwareVersion, NamespacedName}; /// The Message that a Broker sends to a Service during version negotiation. /// /// Defined in /// [Section 5.4.1](https://melt-umn.github.io/monto-v3-draft/draft02/#5-4-1-servicebrokernegotiation) /// of the specification. #[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] pub struct ServiceBrokerNegotiation { /// The version of the Service Protocol the Broker supports. pub monto: ProtocolVersion, /// The version information of the Broker. pub broker: SoftwareVersion, /// The extensions that are supported by the Broker. #[serde(default, skip_serializing_if="BTreeSet::is_empty")] pub extensions: BTreeSet<ServiceExtension>, } /// The Message that a Service sends to a Broker during version negotiation. /// /// Defined in /// [Section 5.4.2](https://melt-umn.github.io/monto-v3-draft/draft02/#5-4-2-servicenegotiation) /// of the specification. #[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] pub struct ServiceNegotiation { /// The version of the Service Protocol the Service supports. pub monto: ProtocolVersion, /// The version information of the Service. pub service: SoftwareVersion, /// The extensions that are supported by the Service. #[serde(default, skip_serializing_if="BTreeSet::is_empty")] pub extensions: BTreeSet<ServiceExtension>, /// The Products the Service can produce. pub products: BTreeSet<ProductDescriptor>, } /// An extension to the Service Protocol. #[derive(Clone, Debug, Deserialize, Eq, Ord, PartialEq, PartialOrd, Serialize)] #[serde(rename_all="snake_case", untagged)] pub enum ServiceExtension { /// An unknown and unsupported extension. Unknown(NamespacedName), } /// The Message that a Service sends to a Broker during version negotiation. /// /// Defined in /// [Section 5.4.3](https://melt-umn.github.io/monto-v3-draft/draft02/#5-4-3-brokerrequest) /// of the specification. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct BrokerRequest { /// The product being requested. pub request: ProductIdentifier, /// Products provided with the request. pub products: Vec<Product>, } /// Errors encountered by a Service. /// /// Defined in /// [Section 5.4.4](https://melt-umn.github.io/monto-v3-draft/draft02/#5-4-4-serviceerrors) /// of the specification. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ServiceErrors { /// The errors encountered. pub errors: Vec<ServiceError>, /// Any notices generated. pub notices: Vec<ServiceNotice>, } /// A single error in a ServiceErrors. /// /// Defined in /// [Section 5.4.4](https://melt-umn.github.io/monto-v3-draft/draft02/#5-4-4-serviceerrors) /// of the specification. #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(content="value", rename_all="snake_case", tag="type")] pub enum ServiceError { /// An error representing a dependency not being present. UnmetDependency(ProductIdentifier), /// A miscellaneous error. Other(String), } /// A response containing a Product from a Service to be returned the Broker. /// /// Defined in /// [Section 5.4.5](https://melt-umn.github.io/monto-v3-draft/draft02/#5-4-5-serviceproduct) /// of the specification. #[derive(Clone, Debug, Deserialize, Serialize)] pub struct ServiceProduct { /// The product sent. pub product: Product, /// Any notices generated. pub notices: Vec<ServiceNotice>, } /// A message from a Broker to the Service signalling a non-error special condition. /// /// Defined in /// [Section 5.4.6](https://melt-umn.github.io/monto-v3-draft/draft02/#5-4-6-servicenotice) /// of the specification. #[derive(Clone, Debug, Deserialize, Serialize)] #[serde(content="value", rename_all="snake_case", tag="type")] pub enum ServiceNotice { /// A notice that a dependency was unused when producing a Product. UnusedDependency(ProductIdentifier), }