Debian Codegraph @

common/types/traits/mapper.go

raw symbols SCIP
1 // Copyright 2018 Google LLC
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package traits
16
17 import "github.com/google/cel-go/common/types/ref"
18
19 // Mapper interface which aggregates the traits of a maps.
20 type Mapper interface {
21 ref.Val
22 Container
23 Indexer
24 Iterable
25 Sizer
26
27 // Find returns a value, if one exists, for the input key.
28 //
29 // If the key is not found the function returns (nil, false).
30 // If the input key is not valid for the map, or is Err or Unknown the function returns
31 // (Unknown|Err, false).
32 Find(key ref.Val) (ref.Val, bool)
33 }
34
35 // MutableMapper interface which emits an immutable result after an intermediate computation.
36 //
37 // Note, this interface is intended only to be used within Comprehensions where the mutable
38 // value is not directly observable within the user-authored CEL expression.
39 type MutableMapper interface {
40 Mapper
41
42 // Insert a key, value pair into the map, returning the map if the insert is successful
43 // and an error if key already exists in the mutable map.
44 Insert(k, v ref.Val) ref.Val
45
46 // ToImmutableMap converts a mutable map into an immutable map.
47 ToImmutableMap() Mapper
48 }