| 1 |
// Copyright 2022 gRPC 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 |
#include <grpc/support/port_platform.h> |
| 16 |
|
| 17 |
#include <stddef.h> |
| 18 |
|
| 19 |
#include <grpc/event_engine/slice.h> |
| 20 |
#include <grpc/event_engine/slice_buffer.h> |
| 21 |
#include <grpc/slice.h> |
| 22 |
#include <grpc/slice_buffer.h> |
| 23 |
|
| 24 |
#include "src/core/lib/slice/slice.h" |
| 25 |
|
| 26 |
namespace grpc_event_engine { |
| 27 |
namespace experimental { |
| 28 |
|
| 29 |
void SliceBuffer::Append(Slice slice) { |
| 30 |
grpc_slice_buffer_add(&slice_buffer_, slice.TakeCSlice()); |
| 31 |
} |
| 32 |
|
| 33 |
size_t SliceBuffer::AppendIndexed(Slice slice) { |
| 34 |
return grpc_slice_buffer_add_indexed(&slice_buffer_, slice.TakeCSlice()); |
| 35 |
} |
| 36 |
|
| 37 |
Slice SliceBuffer::TakeFirst() { |
| 38 |
return Slice(grpc_slice_buffer_take_first(&slice_buffer_)); |
| 39 |
} |
| 40 |
|
| 41 |
void SliceBuffer::Prepend(Slice slice) { |
| 42 |
grpc_slice_buffer_undo_take_first(&slice_buffer_, slice.TakeCSlice()); |
| 43 |
} |
| 44 |
|
| 45 |
Slice SliceBuffer::RefSlice(size_t index) { |
| 46 |
return Slice(grpc_core::CSliceRef(slice_buffer_.slices[index])); |
| 47 |
} |
| 48 |
|
| 49 |
} // namespace experimental |
| 50 |
} // namespace grpc_event_engine |