File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -47,6 +47,22 @@ impl RequestPacket {
47
47
Self :: Batch ( Vec :: with_capacity ( capacity) )
48
48
}
49
49
50
+ /// Returns the [`SerializedRequest`] if this packet is [`ResponsePacket::Single`]
51
+ pub const fn as_single ( & self ) -> Option < & SerializedRequest > {
52
+ match self {
53
+ Self :: Single ( req) => Some ( req) ,
54
+ Self :: Batch ( _) => None ,
55
+ }
56
+ }
57
+
58
+ /// Returns the batch of [`SerializedRequest`] if this packet is [`ResponsePacket::Batch`]
59
+ pub fn as_batch ( & self ) -> Option < & [ SerializedRequest ] > {
60
+ match self {
61
+ Self :: Batch ( req) => Some ( req. as_slice ( ) ) ,
62
+ Self :: Single ( _) => None ,
63
+ }
64
+ }
65
+
50
66
/// Serialize the packet as a boxed [`RawValue`].
51
67
pub fn serialize ( self ) -> serde_json:: Result < Box < RawValue > > {
52
68
match self {
You can’t perform that action at this time.
0 commit comments