Conversation
* feat: add ntex support
maud/src/lib.rs
Outdated
| if self.0.is_empty() { | ||
| Poll::Ready(None) | ||
| } else { | ||
| Poll::Ready(Some(Ok(Bytes::from(mem::take(&mut self.0).into_bytes())))) | ||
| } |
There was a problem hiding this comment.
Can we forward to the implementation for String?
| if self.0.is_empty() { | |
| Poll::Ready(None) | |
| } else { | |
| Poll::Ready(Some(Ok(Bytes::from(mem::take(&mut self.0).into_bytes())))) | |
| } | |
| self.0.poll_next_chunk(context) |
There was a problem hiding this comment.
The implementation follows ntex impl MessageBody for String, avoiding unnecessary allocations and one-shot consumption of the body, performance wise it's the best.
| use crate::PreEscaped; | ||
| use alloc::{rc::Rc, string::String}; | ||
|
|
||
| impl MessageBody for PreEscaped<String> { |
There was a problem hiding this comment.
Is implementing MessageBody necessary here, given that we implement Responder directly?
There was a problem hiding this comment.
The MessageBody adds flexibility, allowing maud to be used anywhere the body it's accepted, not only in the Responder.
Co-authored-by: Chris Wong <lambda.fairy@gmail.com>
|
I'm suggesting to call the String implementation, instead of duplicating it.
…On Mon, Sep 29, 2025, 01:52 David Miguel ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In maud/src/lib.rs
<#482 (comment)>:
> + if self.0.is_empty() {
+ Poll::Ready(None)
+ } else {
+ Poll::Ready(Some(Ok(Bytes::from(mem::take(&mut self.0).into_bytes()))))
+ }
The implementation follows ntex impl MessageBody for String
<https://github.com/ntex-rs/ntex/blob/6d1aa23d929c485710643ae78abbf3f03d4b7514/ntex-http/src/body.rs#L383>,
avoiding unnecessary allocations and one-shot consumption of the body,
performance wise it's the best.
—
Reply to this email directly, view it on GitHub
<#482 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL73Y3NVJQAAVKWA6NVS2L3U773XAVCNFSM6AAAAACG2FFTS6VHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMZTENZXGEYTSMBUGI>
.
You are receiving this because you commented.Message ID:
***@***.***>
|
dvdmgl
left a comment
There was a problem hiding this comment.
I'm more in favor to keep PR as-is, it's copy&paste of actix-web implementation to ntex's, making the transition between frameworks actix-web and ntex easier.
This PR adds support for the Ntex framework.