@@ -277,23 +277,23 @@ pub enum ConsumerInfo {
277277 } ,
278278}
279279
280- #[ derive( Debug , Serialize , JsonSchema ) ]
280+ #[ derive( Debug , PartialEq , Serialize , JsonSchema ) ]
281281pub struct NsidCount {
282282 nsid : String ,
283283 creates : u64 ,
284284 // TODO: add updates and deletes
285285 dids_estimate : u64 ,
286286}
287287
288- #[ derive( Debug , Serialize , JsonSchema ) ]
288+ #[ derive( Debug , PartialEq , Serialize , JsonSchema ) ]
289289pub struct PrefixCount {
290290 prefix : String ,
291291 creates : u64 ,
292292 // TODO: add updates and deletes
293293 dids_estimate : u64 ,
294294}
295295
296- #[ derive( Debug , Serialize , JsonSchema ) ]
296+ #[ derive( Debug , PartialEq , Serialize , JsonSchema ) ]
297297#[ serde( tag = "type" , rename_all = "camelCase" ) ]
298298pub enum PrefixChild {
299299 Collection ( NsidCount ) ,
@@ -303,6 +303,7 @@ pub enum PrefixChild {
303303#[ derive( Debug , Serialize , JsonSchema ) ]
304304pub struct NsidPrefix ( String ) ;
305305impl NsidPrefix {
306+ /// Input must not include a trailing dot.
306307 pub fn new ( pre : & str ) -> EncodingResult < Self > {
307308 // it's a valid prefix if appending `.name` makes it a valid NSID
308309 Nsid :: new ( format ! ( "{pre}.name" ) ) . map_err ( EncodingError :: BadAtriumStringType ) ?;
@@ -319,9 +320,14 @@ impl NsidPrefix {
319320 ) ;
320321 self . 0 == other. domain_authority ( )
321322 }
323+ /// The prefix as initialized (no trailing dot)
322324 pub fn as_str ( & self ) -> & str {
323325 self . 0 . as_str ( )
324326 }
327+ /// The prefix with a trailing `.` appended to avoid matching a longer segment
328+ pub fn terminated ( & self ) -> String {
329+ format ! ( "{}." , self . 0 )
330+ }
325331}
326332
327333#[ derive( Debug , Serialize , JsonSchema ) ]
0 commit comments