@@ -14,9 +14,9 @@ use core::str::FromStr;
14
14
use serde:: de:: { Deserialize , Deserializer , Error , Visitor } ;
15
15
use serde:: ser:: { Serialize , Serializer } ;
16
16
17
- /// NIP90 - Job request range
17
+ /// NIP-90 - Job request range
18
18
pub const NIP90_JOB_REQUEST_RANGE : Range < u16 > = 5_000 ..5_999 ;
19
- /// NIP90 - Job result range
19
+ /// NIP-90 - Job result range
20
20
pub const NIP90_JOB_RESULT_RANGE : Range < u16 > = 6_000 ..6_999 ;
21
21
/// Regular range
22
22
pub const REGULAR_RANGE : Range < u16 > = 1_000 ..10_000 ;
@@ -219,25 +219,11 @@ impl Kind {
219
219
self . as_u16 ( ) as u64
220
220
}
221
221
222
- /// Check if [`Kind`] is a NIP90 job request
223
- ///
224
- /// <https://github.com/nostr-protocol/nips/blob/master/90.md>
225
- #[ inline]
226
- pub fn is_job_request ( & self ) -> bool {
227
- NIP90_JOB_REQUEST_RANGE . contains ( & self . as_u16 ( ) )
228
- }
229
-
230
- /// Check if [`Kind`] is a NIP90 job result
231
- ///
232
- /// <https://github.com/nostr-protocol/nips/blob/master/90.md>
233
- #[ inline]
234
- pub fn is_job_result ( & self ) -> bool {
235
- NIP90_JOB_RESULT_RANGE . contains ( & self . as_u16 ( ) )
236
- }
237
-
238
222
/// Check if it's regular
239
223
///
240
224
/// Regular means that event is expected to be stored by relays.
225
+ ///
226
+ /// <https://github.com/nostr-protocol/nips/blob/master/01.md>
241
227
pub fn is_regular ( & self ) -> bool {
242
228
let kind: u16 = self . as_u16 ( ) ;
243
229
@@ -250,7 +236,12 @@ impl Kind {
250
236
REGULAR_RANGE . contains ( & kind) || !self . is_replaceable ( )
251
237
}
252
238
253
- /// Check if [`Kind`] is `Replaceable`
239
+ /// Check if it's replaceable
240
+ ///
241
+ /// Replaceable means that, for each combination of `pubkey` and `kind`,
242
+ /// only the latest event MUST be stored by relays, older versions MAY be discarded.
243
+ ///
244
+ /// <https://github.com/nostr-protocol/nips/blob/master/01.md>
254
245
#[ inline]
255
246
pub fn is_replaceable ( & self ) -> bool {
256
247
matches ! ( self , Kind :: Metadata )
@@ -259,17 +250,42 @@ impl Kind {
259
250
|| REPLACEABLE_RANGE . contains ( & self . as_u16 ( ) )
260
251
}
261
252
262
- /// Check if [`Kind`] is `Ephemeral`
253
+ /// Check if it's ephemeral
254
+ ///
255
+ /// Ephemeral means that event is not expected to be stored by relays.
256
+ ///
257
+ /// <https://github.com/nostr-protocol/nips/blob/master/01.md>
263
258
#[ inline]
264
259
pub fn is_ephemeral ( & self ) -> bool {
265
260
EPHEMERAL_RANGE . contains ( & self . as_u16 ( ) )
266
261
}
267
262
268
- /// Check if [`Kind`] is `Parameterized replaceable`
263
+ /// Check if it's parameterized replaceable
264
+ ///
265
+ /// Parametrized replaceable means that, for each combination of `pubkey`, `kind` and the `d` tag's first value,
266
+ /// only the latest event MUST be stored by relays, older versions MAY be discarded.
267
+ ///
268
+ /// <https://github.com/nostr-protocol/nips/blob/master/01.md>
269
269
#[ inline]
270
270
pub fn is_parameterized_replaceable ( & self ) -> bool {
271
271
PARAMETERIZED_REPLACEABLE_RANGE . contains ( & self . as_u16 ( ) )
272
272
}
273
+
274
+ /// Check if it's a NIP-90 job request
275
+ ///
276
+ /// <https://github.com/nostr-protocol/nips/blob/master/90.md>
277
+ #[ inline]
278
+ pub fn is_job_request ( & self ) -> bool {
279
+ NIP90_JOB_REQUEST_RANGE . contains ( & self . as_u16 ( ) )
280
+ }
281
+
282
+ /// Check if it's a NIP-90 job result
283
+ ///
284
+ /// <https://github.com/nostr-protocol/nips/blob/master/90.md>
285
+ #[ inline]
286
+ pub fn is_job_result ( & self ) -> bool {
287
+ NIP90_JOB_RESULT_RANGE . contains ( & self . as_u16 ( ) )
288
+ }
273
289
}
274
290
275
291
impl fmt:: Display for Kind {
0 commit comments