| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package datastore | 5 package datastore |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "encoding/base64" | 8 "encoding/base64" |
| 9 "errors" | 9 "errors" |
| 10 "fmt" | 10 "fmt" |
| (...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 673 // error occurs, it's returned via error. If non-fatal conversion errors | 673 // error occurs, it's returned via error. If non-fatal conversion errors |
| 674 // occur, error will be a MultiError containing one or more ErrFieldMism
atch | 674 // occur, error will be a MultiError containing one or more ErrFieldMism
atch |
| 675 // objects. | 675 // objects. |
| 676 Load(PropertyMap) error | 676 Load(PropertyMap) error |
| 677 | 677 |
| 678 // Save returns the current property as a PropertyMap. if withMeta is tr
ue, | 678 // Save returns the current property as a PropertyMap. if withMeta is tr
ue, |
| 679 // then the PropertyMap contains all the metadata (e.g. '$meta' fields) | 679 // then the PropertyMap contains all the metadata (e.g. '$meta' fields) |
| 680 // which was held by this PropertyLoadSaver. | 680 // which was held by this PropertyLoadSaver. |
| 681 Save(withMeta bool) (PropertyMap, error) | 681 Save(withMeta bool) (PropertyMap, error) |
| 682 | 682 |
| 683 MetaGetterSetter | |
| 684 | |
| 685 // Problem indicates that this PLS has a fatal problem. Usually this is | 683 // Problem indicates that this PLS has a fatal problem. Usually this is |
| 686 // set when the underlying struct has recursion, invalid field types, ne
sted | 684 // set when the underlying struct has recursion, invalid field types, ne
sted |
| 687 // slices, etc. | 685 // slices, etc. |
| 688 Problem() error | 686 Problem() error |
| 689 } | 687 } |
| 690 | 688 |
| 691 // MetaGetterSetter is the subset of PropertyLoadSaver which pertains to | 689 // MetaGetterSetter is the subset of PropertyLoadSaver which pertains to |
| 692 // getting and saving metadata. | 690 // getting and saving metadata. |
| 693 // | 691 // |
| 694 // A *struct may implement this interface to provide metadata which is | 692 // A *struct may implement this interface to provide metadata which is |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 843 dflt = UpconvertUnderlyingType(dflt) | 841 dflt = UpconvertUnderlyingType(dflt) |
| 844 cur, err := gm(key) | 842 cur, err := gm(key) |
| 845 if err != nil { | 843 if err != nil { |
| 846 return dflt | 844 return dflt |
| 847 } | 845 } |
| 848 if dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt) { | 846 if dflt != nil && reflect.TypeOf(cur) != reflect.TypeOf(dflt) { |
| 849 return dflt | 847 return dflt |
| 850 } | 848 } |
| 851 return cur | 849 return cur |
| 852 } | 850 } |
| OLD | NEW |