| // Copyright 2019 The Fuchsia Authors. All rights reserved. |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| // |
| // Code generated by third_party/go/regen-fidl; DO NOT EDIT. |
| |
| package mem |
| |
| import ( |
| _zx "syscall/zx" |
| _bindings "syscall/zx/fidl" |
| ) |
| |
| // A buffer for data whose size is not necessarily a multiple of the page |
| // size. |
| // |
| // VMO objects have a physical size that is always a multiple of the page |
| // size. As such, VMO alone cannot serve as a buffer for arbitrarly sized |
| // data. `fuchsia.mem.Buffer` is a standard struct that aggregate the VMO |
| // and its size. |
| type Buffer struct { |
| _ struct{} `fidl:"s" fidl_size_v1:"16" fidl_alignment_v1:"8"` |
| // The vmo that contains the buffer. |
| Vmo _zx.VMO `fidl_offset_v1:"0" fidl_handle_subtype:"3" fidl_handle_rights:"2147483648" fidl_bounds:"0"` |
| // The number of bytes in the buffer. |
| // |
| // The content of the buffer begin at the start of the VMO and continue |
| // for `size` bytes. To specify a range of bytes that do not start at |
| // the beginning of the VMO, use `Range` rather than buffer. |
| // |
| // This size must not be greater than the physical size of the VMO. |
| Size uint64 `fidl_offset_v1:"8"` |
| } |
| |
| var _mBuffer = _bindings.CreateLazyMarshaler(Buffer{}) |
| |
| func (msg *Buffer) Marshaler() _bindings.Marshaler { |
| return _mBuffer |
| } |
| |
| // A range of bytes within a VMO. |
| type Range struct { |
| _ struct{} `fidl:"s" fidl_size_v1:"24" fidl_alignment_v1:"8"` |
| // The vmo that contains the bytes. |
| Vmo _zx.VMO `fidl_offset_v1:"0" fidl_handle_subtype:"3" fidl_handle_rights:"2147483648" fidl_bounds:"0"` |
| // The offset of the first byte within the range relative to the start of |
| // the VMO. |
| // |
| // For example, if `offset` is zero, then the first byte in the range is |
| // the first byte in the VMO. |
| Offset uint64 `fidl_offset_v1:"8"` |
| // The number of bytes in the range. |
| // |
| // For example, if the offset is 3 and the size is 2, and the VMO starts |
| // with "abcdefg...", then the range contains "de". |
| // |
| // The sum of the offset and the size must not be greater than the |
| // physical size of the VMO. |
| Size uint64 `fidl_offset_v1:"16"` |
| } |
| |
| var _mRange = _bindings.CreateLazyMarshaler(Range{}) |
| |
| func (msg *Range) Marshaler() _bindings.Marshaler { |
| return _mRange |
| } |
| |
| type I_dataTag uint64 |
| |
| const ( |
| Data_unknownData = 0 // 0x00000000 |
| DataBytes = 1 // 0x00000001 |
| DataBuffer = 2 // 0x00000002 |
| ) |
| |
| // Binary data that might be stored inline or in a VMO. |
| // |
| // Useful for performance-sensitive protocols that sometimes receive small |
| // amounts of binary data (i.e., which is more efficient to provide using |
| // `bytes`) but also need to support arbitrary amounts of data (i.e., which |
| // need to be provided out-of-line in a `Buffer`). |
| type Data struct { |
| I_dataTag `fidl:"x" fidl_size_v1:"24" fidl_alignment_v1:"8" fidl_resource:"true"` |
| I_unknownData interface{} |
| // The binary data provided inline in the message. |
| Bytes []uint8 `fidl_bounds:"" fidl_ordinal:"1"` |
| // The binary data provided out-of-line in a `Buffer`. |
| Buffer Buffer `fidl_ordinal:"2"` |
| } |
| |
| func (_m *Data) Which() I_dataTag { |
| switch _m.I_dataTag { |
| case 1: |
| return DataBytes |
| case 2: |
| return DataBuffer |
| default: |
| return Data_unknownData |
| } |
| } |
| |
| func (_m *Data) Ordinal() uint64 { |
| return uint64(_m.I_dataTag) |
| } |
| |
| func (_m *Data) SetBytes(bytes []uint8) { |
| _m.I_dataTag = DataBytes |
| _m.Bytes = bytes |
| } |
| |
| func DataWithBytes(bytes []uint8) Data { |
| var _u Data |
| _u.SetBytes(bytes) |
| return _u |
| } |
| |
| func (_m *Data) SetBuffer(buffer Buffer) { |
| _m.I_dataTag = DataBuffer |
| _m.Buffer = buffer |
| } |
| |
| func DataWithBuffer(buffer Buffer) Data { |
| var _u Data |
| _u.SetBuffer(buffer) |
| return _u |
| } |
| func (_m *Data) GetUnknownData() _bindings.UnknownData { |
| return _m.I_unknownData.(_bindings.UnknownData) |
| } |