-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ManagedBufferBuilder removed cache by default
- Loading branch information
1 parent
38e452d
commit 3667386
Showing
4 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,18 @@ | ||
mod managed_buffer_builder; | ||
mod managed_buffer_builder_impl; | ||
mod managed_buffer_builder_impl_basic; | ||
mod managed_buffer_builder_impl_cached; | ||
|
||
pub use managed_buffer_builder::ManagedBufferBuilder; | ||
pub use managed_buffer_builder_impl::ManagedBufferBuilderImpl; | ||
pub use managed_buffer_builder_impl_basic::ManagedBufferBuilderImplBasic; | ||
pub use managed_buffer_builder_impl_cached::ManagedBufferBuilderImplCached; | ||
|
||
#[deprecated(since = "0.48.0", note = "Renamed to ManagedBufferBuilder.")] | ||
pub type ManagedBufferCachedBuilder<M> = ManagedBufferBuilder<M>; | ||
|
||
#[cfg(feature = "managed-buffer-builder-cached")] | ||
pub type ManagedBufferImplDefault<M> = ManagedBufferBuilderImplCached<M>; | ||
|
||
#[cfg(not(feature = "managed-buffer-builder-cached"))] | ||
pub type ManagedBufferImplDefault<M> = ManagedBufferBuilderImplBasic<M>; |
40 changes: 40 additions & 0 deletions
40
framework/base/src/types/managed/wrapped/builder/managed_buffer_builder_impl_basic.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
use crate::{api::ManagedTypeApi, types::ManagedBuffer}; | ||
|
||
use super::ManagedBufferBuilderImpl; | ||
|
||
/// Basic implementation of a ManagedBuffer builder, no caching. | ||
/// | ||
/// It is the ManagedBuffer itself, we just append to it each time. | ||
pub struct ManagedBufferBuilderImplBasic<M> | ||
where | ||
M: ManagedTypeApi, | ||
{ | ||
managed_buffer: ManagedBuffer<M>, | ||
} | ||
|
||
impl<M> ManagedBufferBuilderImpl<M> for ManagedBufferBuilderImplBasic<M> | ||
where | ||
M: ManagedTypeApi, | ||
{ | ||
#[inline] | ||
fn new_from_slice(slice: &[u8]) -> Self { | ||
ManagedBufferBuilderImplBasic { | ||
managed_buffer: slice.into(), | ||
} | ||
} | ||
|
||
#[inline] | ||
fn into_managed_buffer(self) -> ManagedBuffer<M> { | ||
self.managed_buffer | ||
} | ||
|
||
#[inline] | ||
fn append_bytes(&mut self, bytes: &[u8]) { | ||
self.managed_buffer.append_bytes(bytes); | ||
} | ||
|
||
#[inline] | ||
fn append_managed_buffer(&mut self, item: &ManagedBuffer<M>) { | ||
self.managed_buffer.append(item); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters