()
| 25 | ) |
| 26 | |
| 27 | func init() { |
| 28 | parseExprBytesCommonFunc := func(exprsFromBytesFunc func() ([]Any, error)) ([]interface{}, error) { |
| 29 | exprs, err := exprsFromBytesFunc() |
| 30 | if err != nil { |
| 31 | return nil, err |
| 32 | } |
| 33 | result := make([]interface{}, len(exprs)) |
| 34 | for idx, expr := range exprs { |
| 35 | result[idx] = expr |
| 36 | } |
| 37 | return result, nil |
| 38 | } |
| 39 | |
| 40 | parseexprfunc.ParseExprBytesFromNameFunc = func(fam byte, ad *netlink.AttributeDecoder, exprName string) ([]interface{}, error) { |
| 41 | return parseExprBytesCommonFunc(func() ([]Any, error) { |
| 42 | return exprsBytesFromName(fam, ad, exprName) |
| 43 | }) |
| 44 | } |
| 45 | parseexprfunc.ParseExprBytesFunc = func(fam byte, ad *netlink.AttributeDecoder) ([]interface{}, error) { |
| 46 | return parseExprBytesCommonFunc(func() ([]Any, error) { |
| 47 | return exprsFromBytes(fam, ad) |
| 48 | }) |
| 49 | } |
| 50 | parseexprfunc.ParseExprMsgFunc = func(fam byte, b []byte) ([]interface{}, error) { |
| 51 | ad, err := netlink.NewAttributeDecoder(b) |
| 52 | if err != nil { |
| 53 | return nil, err |
| 54 | } |
| 55 | ad.ByteOrder = binary.BigEndian |
| 56 | var exprs []interface{} |
| 57 | for ad.Next() { |
| 58 | e, err := parseexprfunc.ParseExprBytesFunc(fam, ad) |
| 59 | if err != nil { |
| 60 | return e, err |
| 61 | } |
| 62 | exprs = append(exprs, e...) |
| 63 | } |
| 64 | return exprs, ad.Err() |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // Marshal serializes the specified expression into a byte slice. |
| 69 | func Marshal(fam byte, e Any) ([]byte, error) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…