1 // Copyright (C) 2023 The Android Open Source Project
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 use super::Buffer;
16 
17 /// Trait that represents an owner of a buffer that might need to handle events such as a buffer
18 /// being dropped.
19 pub trait BufferOwner: Send + Sync {
20     /// Called when a buffer is dropped.
on_return(&self, buffer: &Buffer)21     fn on_return(&self, buffer: &Buffer);
22 }
23 
24 pub(super) struct NoBufferOwner;
25 
26 impl BufferOwner for NoBufferOwner {
on_return(&self, _buffer: &Buffer)27     fn on_return(&self, _buffer: &Buffer) {}
28 }
29