(val super.Value)
| 122 | } |
| 123 | |
| 124 | func (c *casterNet) Eval(val super.Value) super.Value { |
| 125 | if val.Type().ID() == super.IDNet { |
| 126 | return val |
| 127 | } |
| 128 | if !val.IsString() { |
| 129 | return c.sctx.WrapError("cannot cast to net", val) |
| 130 | } |
| 131 | net, err := netip.ParsePrefix(string(val.Bytes())) |
| 132 | if err != nil { |
| 133 | return c.sctx.WrapError("cannot cast to net", val) |
| 134 | } |
| 135 | return super.NewNet(net) |
| 136 | } |
| 137 | |
| 138 | type casterDuration struct { |
| 139 | sctx *super.Context |