@@ -143,7 +143,7 @@ impl From<&str> for SupportedProtocol {
143143
144144impl From < String > for SupportedProtocol {
145145 fn from ( value : String ) -> Self {
146- SupportedProtocol :: from ( value. as_str ( ) )
146+ Self :: from ( value. as_str ( ) )
147147 }
148148}
149149
@@ -190,49 +190,13 @@ impl From<SupportedProtocol> for String {
190190
191191impl From < & SupportedProtocol > for String {
192192 fn from ( value : & SupportedProtocol ) -> Self {
193- match value {
194- SupportedProtocol :: Clustering => SUPPORTED_PROTOCOL_CLUSTERING . to_owned ( ) ,
195- SupportedProtocol :: AMQP => SUPPORTED_PROTOCOL_AMQP . to_owned ( ) ,
196- SupportedProtocol :: AMQPWithTLS => SUPPORTED_PROTOCOL_AMQP_WITH_TLS . to_owned ( ) ,
197- SupportedProtocol :: Stream => SUPPORTED_PROTOCOL_STREAM . to_owned ( ) ,
198- SupportedProtocol :: StreamWithTLS => SUPPORTED_PROTOCOL_STREAM_WITH_TLS . to_owned ( ) ,
199- SupportedProtocol :: MQTT => SUPPORTED_PROTOCOL_MQTT . to_owned ( ) ,
200- SupportedProtocol :: MQTTWithTLS => SUPPORTED_PROTOCOL_MQTT_WITH_TLS . to_owned ( ) ,
201- SupportedProtocol :: STOMP => SUPPORTED_PROTOCOL_STOMP . to_owned ( ) ,
202- SupportedProtocol :: STOMPWithTLS => SUPPORTED_PROTOCOL_STOMP_WITH_TLS . to_owned ( ) ,
203- SupportedProtocol :: AMQPOverWebSockets => {
204- SUPPORTED_PROTOCOL_AMQP_OVER_WEBSOCKETS . to_owned ( )
205- }
206- SupportedProtocol :: AMQPOverWebSocketsWithTLS => {
207- SUPPORTED_PROTOCOL_AMQP_OVER_WEBSOCKETS_WITH_TLS . to_owned ( )
208- }
209- SupportedProtocol :: MQTTOverWebSockets => {
210- SUPPORTED_PROTOCOL_MQTT_OVER_WEBSOCKETS . to_owned ( )
211- }
212- SupportedProtocol :: MQTTOverWebSocketsWithTLS => {
213- SUPPORTED_PROTOCOL_MQTT_OVER_WEBSOCKETS_WITH_TLS . to_owned ( )
214- }
215- SupportedProtocol :: STOMPOverWebsockets => {
216- SUPPORTED_PROTOCOL_STOMP_OVER_WEBSOCKETS . to_owned ( )
217- }
218- SupportedProtocol :: STOMPOverWebsocketsWithTLS => {
219- SUPPORTED_PROTOCOL_STOMP_OVER_WEBSOCKETS_WITH_TLS . to_owned ( )
220- }
221- SupportedProtocol :: Prometheus => SUPPORTED_PROTOCOL_PROMETHEUS . to_owned ( ) ,
222- SupportedProtocol :: PrometheusWithTLS => {
223- SUPPORTED_PROTOCOL_PROMETHEUS_WITH_TLS . to_owned ( )
224- }
225- SupportedProtocol :: HTTP => SUPPORTED_PROTOCOL_HTTP . to_owned ( ) ,
226- SupportedProtocol :: HTTPWithTLS => SUPPORTED_PROTOCOL_HTTP_WITH_TLS . to_owned ( ) ,
227- SupportedProtocol :: Other ( s) => ( * s) . clone ( ) ,
228- }
193+ value. clone ( ) . into ( )
229194 }
230195}
231196
232197impl fmt:: Display for SupportedProtocol {
233198 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
234- let proto: String = self . into ( ) ;
235- write ! ( f, "{proto}" )
199+ write ! ( f, "{}" , String :: from( self ) )
236200 }
237201}
238202
@@ -316,7 +280,7 @@ impl From<&str> for ExchangeType {
316280
317281impl From < String > for ExchangeType {
318282 fn from ( value : String ) -> Self {
319- ExchangeType :: from ( value. as_str ( ) )
283+ Self :: from ( value. as_str ( ) )
320284 }
321285}
322286
@@ -381,13 +345,7 @@ impl From<&str> for QueueType {
381345
382346impl From < String > for QueueType {
383347 fn from ( value : String ) -> Self {
384- let val = value. to_ascii_lowercase ( ) ;
385- match val. as_str ( ) {
386- "classic" => QueueType :: Classic ,
387- "quorum" => QueueType :: Quorum ,
388- "stream" => QueueType :: Stream ,
389- _ => QueueType :: Unsupported ( value) ,
390- }
348+ Self :: from ( value. as_str ( ) )
391349 }
392350}
393351
@@ -444,11 +402,7 @@ impl From<&str> for BindingDestinationType {
444402
445403impl From < String > for BindingDestinationType {
446404 fn from ( value : String ) -> Self {
447- match value. as_str ( ) {
448- "queue" => BindingDestinationType :: Queue ,
449- "exchange" => BindingDestinationType :: Exchange ,
450- _ => BindingDestinationType :: Queue ,
451- }
405+ Self :: from ( value. as_str ( ) )
452406 }
453407}
454408
@@ -568,20 +522,7 @@ impl From<&str> for PolicyTarget {
568522
569523impl From < String > for PolicyTarget {
570524 fn from ( value : String ) -> Self {
571- match value. as_str ( ) {
572- "queues" => PolicyTarget :: Queues ,
573- "queue" => PolicyTarget :: Queues ,
574- "classic_queues" => PolicyTarget :: ClassicQueues ,
575- "classic_queue" => PolicyTarget :: ClassicQueues ,
576- "quorum_queues" => PolicyTarget :: QuorumQueues ,
577- "quorum_queue" => PolicyTarget :: QuorumQueues ,
578- "streams" => PolicyTarget :: Streams ,
579- "stream" => PolicyTarget :: Streams ,
580- "exchanges" => PolicyTarget :: Exchanges ,
581- "exchange" => PolicyTarget :: Exchanges ,
582- "all" => PolicyTarget :: All ,
583- _ => PolicyTarget :: Queues ,
584- }
525+ Self :: from ( value. as_str ( ) )
585526 }
586527}
587528
@@ -626,11 +567,7 @@ impl From<&str> for VirtualHostLimitTarget {
626567
627568impl From < String > for VirtualHostLimitTarget {
628569 fn from ( value : String ) -> Self {
629- match value. as_str ( ) {
630- "max-connections" => VirtualHostLimitTarget :: MaxConnections ,
631- "max-queues" => VirtualHostLimitTarget :: MaxQueues ,
632- _ => VirtualHostLimitTarget :: MaxConnections ,
633- }
570+ Self :: from ( value. as_str ( ) )
634571 }
635572}
636573
@@ -668,11 +605,7 @@ impl From<&str> for UserLimitTarget {
668605
669606impl From < String > for UserLimitTarget {
670607 fn from ( value : String ) -> Self {
671- match value. as_str ( ) {
672- "max-connections" => UserLimitTarget :: MaxConnections ,
673- "max-channels" => UserLimitTarget :: MaxChannels ,
674- _ => UserLimitTarget :: MaxConnections ,
675- }
608+ Self :: from ( value. as_str ( ) )
676609 }
677610}
678611
0 commit comments