Skip to content

Commit 1fac84b

Browse files
committed
feat(binding_coap): add tryParse method to CoapSubprotocol
1 parent 30a9cf8 commit 1fac84b

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

lib/src/binding_coap/coap_definitions.dart

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,15 @@ enum CoapRequestMethod {
5555
enum CoapSubprotocol {
5656
/// Subprotocol for observing CoAP resources.
5757
observe,
58+
;
59+
60+
/// Tries to match the given [subprotocol] string to one of the known
61+
/// [CoapSubprotocol.values].
62+
static CoapSubprotocol? tryParse(String subprotocol) {
63+
if (subprotocol == "cov:observe") {
64+
return CoapSubprotocol.observe;
65+
}
66+
67+
return null;
68+
}
5869
}

0 commit comments

Comments
 (0)