1
0
mirror of https://github.com/esphome/esphome.git synced 2026-02-08 00:31:58 +00:00

[api] Enable zero-copy bytes SOURCE_BOTH messages (#12816)

This commit is contained in:
J. Nick Koston
2026-01-02 19:50:30 -10:00
committed by GitHub
parent c4d339a4c9
commit 2a5be725c8
3 changed files with 13 additions and 13 deletions

View File

@@ -362,12 +362,12 @@ def create_field_type_info(
# Traditional fixed array approach with copy (takes priority)
return FixedArrayBytesType(field, fixed_size)
# For SOURCE_CLIENT only messages (decode but no encode), use pointer
# For messages that decode (SOURCE_CLIENT or SOURCE_BOTH), use pointer
# for zero-copy access to the receive buffer
if needs_decode and not needs_encode:
if needs_decode:
return PointerToBytesBufferType(field, None)
# For SOURCE_BOTH/SOURCE_SERVER, explicit annotation is still needed
# For SOURCE_SERVER (encode only), explicit annotation is still needed
if get_field_opt(field, pb.pointer_to_buffer, False):
return PointerToBytesBufferType(field, None)