func LoadFromReader(r io.Reader) (*Rules, error) { var handle *C.YR_RULES code := C.yr_rules_load_stream(readStream(r), &handle) if code != C.ERROR_SUCCESS { return nil, Error(code) } return &Rules{handle}, nil }
// ReadRules retrieves a compiled ruleset from an io.Reader func ReadRules(rd io.Reader) (*Rules, error) { var yrRules *C.YR_RULES var stream C.YR_STREAM stream.user_data = unsafe.Pointer(&rd) stream.read = C.YR_STREAM_READ_FUNC(C.stream_read) if err := newError(C.yr_rules_load_stream(&stream, &yrRules)); err != nil { return nil, err } r := &Rules{rules: &rules{cptr: yrRules}} runtime.SetFinalizer(r.rules, (*rules).finalize) return r, nil }