github.com/ystia/yorc/v4@v4.3.0/storage/encoding/codec.go (about) 1 // Copyright 2019 Bull S.A.S. Atos Technologies - Bull, Rue Jean Jaures, B.P.68, 78340, Les Clayes-sous-Bois, France. 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 encoding 16 17 // Codec encodes/decodes Go values to/from slices of bytes. 18 type Codec interface { 19 // Marshal encodes a Go value to a slice of bytes. 20 Marshal(v interface{}) ([]byte, error) 21 // Unmarshal decodes a slice of bytes into a Go value. 22 Unmarshal(data []byte, v interface{}) error 23 } 24 25 // Convenience variables 26 var ( 27 // JSON is a JSONcodec that encodes/decodes Go values to/from JSON. 28 JSON = JSONcodec{} 29 // Gob is a GobCodec that encodes/decodes Go values to/from gob. 30 Gob = GobCodec{} 31 )