go.chromium.org/luci@v0.0.0-20240309015107-7cdc2e660f33/luci_notify/api/config/proto_gae.gen.go (about)

     1  // Copyright 2017 The LUCI Authors.
     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  // Code generated by gae/tools/proto-gae/proto_gae.go. DO NOT EDIT.
    16  
    17  //go:build !copybara
    18  // +build !copybara
    19  
    20  package config
    21  
    22  import (
    23  	"google.golang.org/protobuf/proto"
    24  
    25  	"go.chromium.org/luci/gae/service/datastore"
    26  )
    27  
    28  var _ datastore.PropertyConverter = (*Notifications)(nil)
    29  
    30  // ToProperty implements datastore.PropertyConverter. It causes an embedded
    31  // 'Notifications' to serialize to an unindexed '[]byte' when used with the
    32  // "go.chromium.org/luci/gae" library.
    33  func (p *Notifications) ToProperty() (prop datastore.Property, err error) {
    34  	data, err := proto.Marshal(p)
    35  	if err == nil {
    36  		prop.SetValue(data, datastore.NoIndex)
    37  	}
    38  	return
    39  }
    40  
    41  // FromProperty implements datastore.PropertyConverter. It parses a '[]byte'
    42  // into an embedded 'Notifications' when used with the "go.chromium.org/luci/gae" library.
    43  func (p *Notifications) FromProperty(prop datastore.Property) error {
    44  	data, err := prop.Project(datastore.PTBytes)
    45  	if err != nil {
    46  		return err
    47  	}
    48  	return proto.Unmarshal(data.([]byte), p)
    49  }
    50  
    51  var _ datastore.PropertyConverter = (*TreeCloser)(nil)
    52  
    53  // ToProperty implements datastore.PropertyConverter. It causes an embedded
    54  // 'TreeCloser' to serialize to an unindexed '[]byte' when used with the
    55  // "go.chromium.org/luci/gae" library.
    56  func (p *TreeCloser) ToProperty() (prop datastore.Property, err error) {
    57  	data, err := proto.Marshal(p)
    58  	if err == nil {
    59  		prop.SetValue(data, datastore.NoIndex)
    60  	}
    61  	return
    62  }
    63  
    64  // FromProperty implements datastore.PropertyConverter. It parses a '[]byte'
    65  // into an embedded 'TreeCloser' when used with the "go.chromium.org/luci/gae" library.
    66  func (p *TreeCloser) FromProperty(prop datastore.Property) error {
    67  	data, err := prop.Project(datastore.PTBytes)
    68  	if err != nil {
    69  		return err
    70  	}
    71  	return proto.Unmarshal(data.([]byte), p)
    72  }