Skip to content

Commit df949c7

Browse files
Add QueueOps#name, QueueType#is_server_named
1 parent 26f0ad8 commit df949c7

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

CHANGELOG.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,12 @@
44

55
### Enhancements
66

7-
* `QueueOps#x_arguments` is a new method that returns the optional arguments of an object (`XArguments`)
8-
* `QueueOps#has_queue_ttl_arg` is a new method that returns true if optional arguments of an object include a queue TTL argument (`"x-expires"`)
7+
* `QueueOps#x_arguments`: returns the optional arguments of an object (`XArguments`)
8+
* `QueueOps#has_queue_ttl_arg`: returns true if optional arguments of an object include a queue TTL argument (`"x-expires"`)
99
* `QueueOps#has_message_ttl_arg`: returns true if optional arguments of an object include a message TTL argument (`"x-message-ttl"`)
1010
* `QueueOps#has_length_limit_in_messages`: returns true if optional arguments of an object include a queue length limit in messages (`"x-max-length"`)
1111
* `QueueOps#has_length_limit_in_bytes`: returns true if optional arguments of an object include a queue length limit in bytes (`"x-max-length-bytes"`)
12+
* `QueueOps#is_server_named`: returns true if an object's name suggests it is a server-named (system) entity.
1213

1314

1415

src/responses.rs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -771,6 +771,9 @@ impl fmt::Display for NameAndVirtualHost {
771771
}
772772

773773
pub trait QueueOps {
774+
/// Returns the name of the object.
775+
fn name(&self) -> &str;
776+
774777
/// Returns the [`QueueType`] applicable to the implementation.
775778
fn queue_type(&self) -> QueueType;
776779

@@ -793,15 +796,25 @@ pub trait QueueOps {
793796
.contains_key(XArguments::X_MESSAGE_TTL_KEY)
794797
}
795798

799+
/// Returns true if one of the optional arguments
800+
/// of the implementation is [`XArguments::X_MAX_LENGTH_KEY`] ("x-max-length")
796801
fn has_length_limit_in_messages(&self) -> bool {
797802
self.x_arguments()
798803
.contains_key(XArguments::X_MAX_LENGTH_KEY)
799804
}
800805

806+
/// Returns true if one of the optional arguments
807+
/// of the implementation is [`XArguments::X_MAX_LENGTH_BYTES_KEY`] ("x-max-length-bytes")
801808
fn has_length_limit_in_bytes(&self) -> bool {
802809
self.x_arguments()
803810
.contains_key(XArguments::X_MAX_LENGTH_BYTES_KEY)
804811
}
812+
813+
/// Returns true if the name of the queue starts with `amq.`,
814+
/// that is, the queue is server-named.
815+
fn is_server_named(&self) -> bool {
816+
self.name().starts_with("amq.")
817+
}
805818
}
806819

807820
#[derive(Debug, Deserialize, Clone)]
@@ -875,6 +888,10 @@ pub struct QueueInfo {
875888
}
876889

877890
impl QueueOps for QueueInfo {
891+
fn name(&self) -> &str {
892+
&self.name
893+
}
894+
878895
fn queue_type(&self) -> QueueType {
879896
QueueType::from(self.queue_type.as_str())
880897
}
@@ -937,6 +954,10 @@ impl NamedPolicyTargetObject for QueueDefinition {
937954
}
938955

939956
impl QueueOps for QueueDefinition {
957+
fn name(&self) -> &str {
958+
&self.name
959+
}
960+
940961
fn queue_type(&self) -> QueueType {
941962
if let Some((_, val)) = self.arguments.0.get_key_value(X_ARGUMENT_KEY_X_QUEUE_TYPE) {
942963
val.as_str()
@@ -1048,6 +1069,10 @@ pub struct QueueDefinitionWithoutVirtualHost {
10481069
}
10491070

10501071
impl QueueOps for QueueDefinitionWithoutVirtualHost {
1072+
fn name(&self) -> &str {
1073+
&self.name
1074+
}
1075+
10511076
fn queue_type(&self) -> QueueType {
10521077
if let Some((_, val)) = self.arguments.0.get_key_value(X_ARGUMENT_KEY_X_QUEUE_TYPE) {
10531078
val.as_str()

0 commit comments

Comments
 (0)