本文整理汇总了Golang中github.com/maybebtc/interplanetary/Godeps/_workspace/src/github.com/jbenet/go-ipfs/unixfs/pb.Data.Data方法的典型用法代码示例。如果您正苦于以下问题:Golang Data.Data方法的具体用法?Golang Data.Data怎么用?Golang Data.Data使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/maybebtc/interplanetary/Godeps/_workspace/src/github.com/jbenet/go-ipfs/unixfs/pb.Data
的用法示例。
在下文中一共展示了Data.Data方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: GetBytes
func (mb *MultiBlock) GetBytes() ([]byte, error) {
pbn := new(pb.Data)
t := pb.Data_File
pbn.Type = &t
pbn.Filesize = proto.Uint64(uint64(len(mb.Data)) + mb.subtotal)
pbn.Blocksizes = mb.blocksizes
pbn.Data = mb.Data
return proto.Marshal(pbn)
}
示例2: WrapData
func WrapData(b []byte) []byte {
pbdata := new(pb.Data)
typ := pb.Data_Raw
pbdata.Data = b
pbdata.Type = &typ
out, err := proto.Marshal(pbdata)
if err != nil {
// This shouldnt happen. seriously.
panic(err)
}
return out
}
示例3: FilePBData
func FilePBData(data []byte, totalsize uint64) []byte {
pbfile := new(pb.Data)
typ := pb.Data_File
pbfile.Type = &typ
pbfile.Data = data
pbfile.Filesize = proto.Uint64(totalsize)
data, err := proto.Marshal(pbfile)
if err != nil {
// This really shouldnt happen, i promise
// The only failure case for marshal is if required fields
// are not filled out, and they all are. If the proto object
// gets changed and nobody updates this function, the code
// should panic due to programmer error
panic(err)
}
return data
}