feat(ksuid): add Equal and IsZero for ApplyInterfacePtr

StringKSUID and BinaryKSUID now implement ApplyInterface with nil-nil
equality semantics, enabling ApplyInterfacePtr in patch logic. Adds nil
sentinel vars and tests.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-06-29 18:24:07 -07:00
parent 0f8e79a890
commit cc44931ea9
6 changed files with 69 additions and 3 deletions
+14
View File
@@ -15,6 +15,20 @@ type StringKSUID struct {
ksuid.KSUID
}
// NilStringKSUID is the zero/nil StringKSUID value.
var NilStringKSUID = StringKSUID{KSUID: ksuid.Nil}
// Equal reports whether two StringKSUID values represent the same identifier,
// treating two nil values as equal. Implements [ApplyInterface].
func (s StringKSUID) Equal(rh StringKSUID) bool {
return equalKSUID(s.KSUID, rh.KSUID)
}
// IsZero reports whether s is nil. Implements [ApplyInterface].
func (s StringKSUID) IsZero() bool {
return s.IsNil()
}
// NewStringKSUID generates a new StringKSUID.
func NewStringKSUID() StringKSUID {
return StringKSUID{KSUID: ksuid.New()}