MCPcopy Create free account
hub / github.com/cel-expr/cel-go / ConvertToNative

Method ConvertToNative

ext/network.go:568–576  ·  view source on GitHub ↗

ConvertToNative converts the CIDR value to a native Go type.

(typeDesc reflect.Type)

Source from the content-addressed store, hash-verified

566
567// ConvertToNative converts the CIDR value to a native Go type.
568func (c CIDR) ConvertToNative(typeDesc reflect.Type) (any, error) {
569 if typeDesc == reflect.TypeFor[netip.Prefix]() {
570 return c.Prefix, nil
571 }
572 if typeDesc.Kind() == reflect.String {
573 return c.Prefix.String(), nil
574 }
575 return nil, fmt.Errorf("unsupported type conversion to '%v'", typeDesc)
576}
577
578// ConvertToType converts the CIDR value to a CEL type.
579func (c CIDR) ConvertToType(typeValue ref.Type) ref.Val {

Callers 1

Calls 2

KindMethod · 0.65
StringMethod · 0.65

Tested by 1