[
https://issues.apache.org/jira/browse/THRIFT-6288?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18116517#comment-18116517
]
Jens Geyer commented on THRIFT-6288:
------------------------------------
PR #3880 rewords the comments instead of adding a transport API. One correction
to the description first: the quoted TODO is not the text in the tree. Since
THRIFT-5871, {{check_container_size}} has said:
{noformat}
// TODO: When Rust trait specialization stabilizes, we can add more precise
checks
// for transports that track exact remaining bytes. For now, we use the message
// size limit as a best-effort check.
{noformat}
That comment names a real obstacle. {{TReadTransport}} is implemented for every
{{io::Read}} by one blanket impl, so a transport cannot supply its own count of
remaining bytes until specialization is stable. The THRIFT-5871 commit message
says the same.
The PR keeps the TODO and makes it say three things:
* the check compares against the whole {{max_message_size}}, not against what
is left of the current message;
* why that is so;
* up-front allocation does not depend on the check.
The two TODOs in {{read_message_begin}} (binary and compact) now refer to it.
Only comments change.
_Drafted with AI assistance (Claude Opus 5); reviewed and posted by Jens Geyer._
> Rust: the stale remaining-bytes TODO in check_container_size
> ------------------------------------------------------------
>
> Key: THRIFT-6288
> URL: https://issues.apache.org/jira/browse/THRIFT-6288
> Project: Thrift
> Issue Type: Improvement
> Components: Rust - Library
> Reporter: Jens Geyer
> Assignee: Jens Geyer
> Priority: Minor
> Fix For: 0.25.0
>
> Time Spent: 20m
> Remaining Estimate: 0h
>
> {{check_container_size}} in {{lib/rs/src/protocol/mod.rs}} carries a {{TODO}}
> saying a remaining-bytes check is still pending for transports that track
> exact remaining bytes:
> {code}
> // TODO: Add a check for the maximum number of bytes remaining in the buffer
> // for transports that track exact remaining bytes. For now, we use the
> message
> // size limit as an approximation.
> {code}
> No Rust transport reports remaining bytes -- {{TReadTransport}} is
> {{io::Read}}, which has no such notion -- so the note points at an approach
> the binding cannot take as written, and reads as an unfinished check when the
> limit is in fact the one that applies.
> h2. Suggested
> Either add a remaining-bytes notion to {{TReadTransport}} (a real API
> addition, parity with the transports in Go/Java/C++/netstd that do report it)
> or reword the comment to state that Rust bounds a container by the configured
> limit alone.
> _Drafted with AI assistance (Claude Opus 4.8); reviewed and filed by Jens
> Geyer._
--
This message was sent by Atlassian Jira
(v8.20.10#820010)