@@ -180,6 +180,7 @@ pub fn query_mine(
180
180
target : Option < AnyLinkableHash > ,
181
181
content_full : Option < String > ,
182
182
content_starts_with : Option < String > ,
183
+ content_not_starts_with : Option < String > ,
183
184
value_starts_with : Option < String > ,
184
185
) -> ExternResult < Vec < TrustAtom > > {
185
186
let agent_address = AnyLinkableHash :: from ( agent_info ( ) ?. agent_initial_pubkey ) ;
@@ -189,6 +190,7 @@ pub fn query_mine(
189
190
target,
190
191
content_full,
191
192
content_starts_with,
193
+ content_not_starts_with,
192
194
value_starts_with,
193
195
) ?;
194
196
@@ -204,6 +206,7 @@ pub fn query(
204
206
target : Option < AnyLinkableHash > ,
205
207
content_full : Option < String > ,
206
208
content_starts_with : Option < String > ,
209
+ content_not_starts_with : Option < String > ,
207
210
value_starts_with : Option < String > ,
208
211
) -> ExternResult < Vec < TrustAtom > > {
209
212
let ( link_direction, link_base) = match ( source, target) {
@@ -217,27 +220,56 @@ pub fn query(
217
220
}
218
221
} ;
219
222
223
+ if let Some ( content_not_starts_with_string) = content_not_starts_with {
224
+ if content_full. is_some ( ) || content_starts_with. is_some ( ) || value_starts_with. is_some ( ) {
225
+ return Err ( wasm_error ! (
226
+ "Passing content_not_starts_with means content_full, content_starts_with, and value_starts_with must all be None"
227
+ ) ) ;
228
+ }
229
+ let links = get_links ( link_base. clone ( ) , LinkTypes :: TrustAtom , None ) ?;
230
+ let trust_atoms = convert_links_to_trust_atoms ( links, & link_direction, link_base) ?;
231
+ let filtered_trust_atoms = trust_atoms
232
+ . into_iter ( )
233
+ . filter ( |trust_atom| {
234
+ let content_option = trust_atom. content . clone ( ) ;
235
+ if let Some ( content) = content_option {
236
+ if content. starts_with ( content_not_starts_with_string. as_str ( ) ) {
237
+ return false ;
238
+ }
239
+ }
240
+ true
241
+ } )
242
+ . collect ( ) ;
243
+ return Ok ( filtered_trust_atoms) ;
244
+ }
245
+
220
246
let link_tag = match ( content_full, content_starts_with, value_starts_with) {
221
247
( Some ( _content_full) , Some ( _content_starts_with) , _) => {
222
- return Err ( wasm_error ! ( "Only one of `content_full` or `content_starts_with` can be used" ) )
223
- } ,
248
+ return Err ( wasm_error ! (
249
+ "Only one of `content_full` or `content_starts_with` can be used"
250
+ ) )
251
+ }
224
252
( _, Some ( _content_starts_with) , Some ( _value_starts_with) ) => {
225
253
return Err ( wasm_error ! (
226
254
"Cannot use `value_starts_with` and `content_starts_with` arguments together; maybe try `content_full` instead?" ,
227
- ) )
228
- } ,
255
+ ) ) ;
256
+ }
229
257
( Some ( content_full) , None , Some ( value_starts_with) ) => Some ( create_link_tag (
230
258
& link_direction,
231
259
& [ Some ( content_full) , Some ( value_starts_with) ] ,
232
260
) ) ,
233
- ( Some ( content_full) , None , None ) => {
234
- Some ( create_link_tag_metal ( & link_direction, vec ! [ content_full, UNICODE_NUL_STR . to_string( ) ] ) )
235
- } ,
261
+ ( Some ( content_full) , None , None ) => Some ( create_link_tag_metal (
262
+ & link_direction,
263
+ vec ! [ content_full, UNICODE_NUL_STR . to_string( ) ] ,
264
+ ) ) ,
236
265
( None , Some ( content_starts_with) , None ) => Some ( create_link_tag (
237
266
& link_direction,
238
267
& [ Some ( content_starts_with) ] ,
239
268
) ) ,
240
- ( None , None , Some ( value_starts_with) ) => Some ( create_link_tag ( & link_direction, & [ Some ( value_starts_with) ] ) ) ,
269
+ ( None , None , Some ( value_starts_with) ) => Some ( create_link_tag (
270
+ & link_direction,
271
+ & [ None , Some ( value_starts_with) ] ,
272
+ ) ) ,
241
273
( None , None , None ) => None ,
242
274
} ;
243
275
let links = get_links ( link_base. clone ( ) , LinkTypes :: TrustAtom , link_tag) ?;
0 commit comments