Is there a data structure somewhere in the unit that contains a list of desired trinkets and their material(s)? A 'I want to acquire a ring, preferably dolomite' entry, if you will?
That would be the unit's preferences (that list you can see where it explains materials, creatures, art forms, etc. that they like). The preferences are stored in the unit's unit.status.current_soul.preferences.
For a material preference: type will be 0 (df.unit_preference.T_type[0] is LikeMaterial). mattype and matindex are the type and index of the material. You can use dfhack.matinfo.find(TOKEN), where TOKEN is the material's token (e.g. "INORGANIC:GOLD", "COW:MILK") to find the material, and then use its .type and .index info to fill in mattype and matindex respectively.
For an item preference: type will be 4 (df.unit_preference.T_type[4] is LikeItem). item_type will be the item's type (df.item_type). Conveniently, the numerical ids and tokens are listed on
this wiki page, so set the item_type value to either the number listed or use df.item_type[TOKEN] (e.g. for blocks use 2 or df.item_type.BLOCKS). item_subtype will be -1 for items without subtype. For items with subtypes (weapons, trap components, toys, tools, instruments, armor, ammo, siege_ammo, gloves, shields, helms, pants, food) you use that item's subtype. I don't know if there's any direct way of finding a subtype by a string, but all items with subtypes are listed in df.global.world.raws.itemdefs.all (or instead of .all you can use stuff like .weapons to only get the weapon itemdefs). From within that table, it'd simply be a case of looping through it until you find the desired id (the token of the item subtype e.g. "ITEM_WEAPON_CROSSBOW") and using the subtype entry for the item_subtype (so again in this example crossbows have a subtype of 6).
You're lucky I just recently looked into all of this