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

Function NewStringSourceWithLimit

common/source.go:96–109  ·  view source on GitHub ↗

NewStringSourceWithLimit creates a new Source from the given contents and description while enforcing a maximum code point count when needed.

(contents string, description string, limit int)

Source from the content-addressed store, hash-verified

94// NewStringSourceWithLimit creates a new Source from the given contents and
95// description while enforcing a maximum code point count when needed.
96func NewStringSourceWithLimit(contents string, description string, limit int) (Source, error) {
97 if limit < 0 || len(contents) <= limit {
98 return NewStringSource(contents, description), nil
99 }
100 buf, offs, err := runes.NewBufferAndLineOffsetsWithLimit(contents, limit)
101 if err != nil {
102 return nil, err
103 }
104 return &sourceImpl{
105 Buffer: buf,
106 description: description,
107 lineOffsets: offs,
108 }, nil
109}
110
111// NewInfoSource creates a new Source from a SourceInfo.
112func NewInfoSource(info *exprpb.SourceInfo) Source {

Callers 1

NewTextSourceWithLimitFunction · 0.85

Calls 2

NewStringSourceFunction · 0.85

Tested by

no test coverage detected