async_codegen/rust/mod.rs
1/*
2 * Copyright © 2025 Anand Beh
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//!
18//! Rust syntax elements.
19//!
20//! Note that no checking exists to make sure the elements are used correctly, i.e. the correct
21//! combination of structs. Instead, the library user is expected to have basic knowledge of how
22//! Rust syntax is composed, and to combine the structs in this module likewise.
23//!
24//! Example:
25//!
26//! ```
27//! # use async_codegen::common::{CombinedSeq, NoOpSeq, SingularSeq, Str};
28//! # use async_codegen::{Output, Writable};
29//! # use async_codegen::rust::{CanHaveAttributes, CfgAttr, Deprecated, FunctionBodyImplement, FunctionDef, FunctionParam, ModPub, MustUse, NoMangle, Parameterized};
30//!
31//! async fn write_function<O>(output: &mut O) -> Result<(), O::Error> where O: Output {
32//! // For more advanced usage, you can replace Str("") by other Writable implementations
33//! let function_def = FunctionDef {
34//! mods: SingularSeq(ModPub),
35//! name: Str("my_func"),
36//! args: CombinedSeq(
37//! SingularSeq(FunctionParam(Str("var1"), Str("Type"))),
38//! SingularSeq(FunctionParam(Str("var2"), Parameterized::new(Str("Option"), SingularSeq(Str("bool")))))
39//! ),
40//! return_type: Parameterized::new(Str("Box"), SingularSeq(Str("str"))),
41//! where_conds: NoOpSeq,
42//! body: FunctionBodyImplement(Str("todo!()"))
43//! };
44//! function_def.write_to(output).await
45//! // Will render as:
46//! /*
47//! pub fn my_func(var1: Type, var2: Option<bool>) -> Box<str> {
48//! todo!()
49//! }
50//! */
51//! }
52//! ```
53//!
54
55use crate::common::{Combined, NoOp, NoOpSeq, Str, SurroundingSeqAccept};
56use crate::{Output, SequenceAccept, Writable};
57use std::fmt::Debug;
58
59mod syntax;
60#[cfg(test)]
61mod tests;
62
63/// All possible Rust editions.
64/// This is the only type in this module meant to be used as context, and not as a writable itself.
65#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord)]
66#[non_exhaustive]
67pub enum Edition {
68 /// This Rust edition is declared for usability purposes. However, not all [crate::Writable]
69 /// implementations are guaranteed to work with it.
70 Rust2015,
71 Rust2018,
72 Rust2021,
73 Rust2024,
74}
75
76/// An attribute enabled conditionally, i.e. `#[cfg_attr(Cond, Attr)]`
77#[derive(Clone, Debug)]
78pub struct CfgAttr<Cond, Attr>(pub Cond, pub Attr);
79
80/// A cfg attribute. Renders as `cfg(Cond)`.
81#[derive(Clone, Debug)]
82pub struct Cfg<Cond>(pub Cond);
83
84/// A cfg condition for targeting an OS, OS family, or architecture. For example:
85/// ```
86/// # use async_codegen::common::{NoOpSeq, SingularSeq, Str};
87/// # use async_codegen::context::EmptyContext;
88/// # use async_codegen::rust::{FunctionBodyDeclare, Cfg, FunctionDef, Target, CanHaveAttributes};
89/// # use async_codegen::util::InMemoryOutput;
90/// let function = FunctionDef {
91/// mods: NoOpSeq,
92/// name: Str("conditional_func"),
93/// args: NoOpSeq,
94/// return_type: Str("()"),
95/// where_conds: NoOpSeq,
96/// body: FunctionBodyDeclare
97/// }.with_attributes(
98/// SingularSeq(Cfg(Target::Os(Str("linux"))))
99/// );
100/// let string = InMemoryOutput::print_output(EmptyContext, &function);
101/// assert_eq!("#[cfg(target_os = \"linux\")]\nfn conditional_func() -> ();\n", string);
102/// ```
103#[derive(Clone, Debug)]
104pub enum Target<Value> {
105 Os(Value),
106 Family(Value),
107 Arch(Value),
108}
109
110/// The link attribute.
111#[derive(Clone, Debug)]
112pub struct Link<Arg>(pub Arg);
113
114/// The no mangle attribute.
115///
116/// Requires that the context satisfies [ContextProvides] for [Edition], because in Rust 2024 and
117/// beyond, the no-mangle attribute is an unsafe attribute.
118#[derive(Clone, Debug)]
119pub struct NoMangle;
120
121/// The attribute content for `allow(...)`. The tuple value must be a sequence.
122#[derive(Clone, Debug)]
123pub struct AllowLints<Lints>(pub Lints);
124
125/// The deprecated attribute. The three variants of this enum correspond to the deprecated
126/// attribute's multiple ways of being specified. See:
127/// https://doc.rust-lang.org/reference/attributes/diagnostics.html#the-deprecated-attribute
128#[derive(Clone, Debug)]
129pub enum Deprecated<Msg, Since = NoOp> {
130 Basic,
131 Message(Msg),
132 Full { since: Since, note: Msg },
133}
134
135impl Default for Deprecated<NoOp, NoOp> {
136 fn default() -> Self {
137 Self::Basic
138 }
139}
140
141impl Deprecated<NoOp, NoOp> {
142 pub fn basic() -> Self {
143 Self::Basic
144 }
145}
146
147impl<Msg> Deprecated<Msg> {
148 pub fn with_message(msg: Msg) -> Self {
149 Self::Message(msg)
150 }
151}
152
153/// The must_use attribute
154#[derive(Clone, Debug)]
155pub struct MustUse;
156
157/// The public modifier
158#[derive(Clone, Debug)]
159pub struct ModPub;
160
161/// The extern modifier, with the ABI selected as the tuple value.
162///
163/// This struct includes `unsafe`. Since Rust 2024, the unsafe keyword is required for extern
164/// functions, and before Rust 2024 it is optional. To make it easy to generate code targeting
165/// multiple editions, we unconditionally emit the "unsafe" keyword alongside "extern".
166#[derive(Clone, Debug)]
167pub struct ModUnsafeExtern<Abi>(pub Abi);
168
169/// A let statement. This statement includes the semicolon and a new line.
170#[derive(Clone, Debug)]
171pub struct LetStmt<Variable, Expr>(pub Variable, pub Expr);
172
173/// An assignation. This statement includes the semicolon and a new line.
174#[derive(Clone, Debug)]
175pub struct AssignStmt<Variable, Expr>(pub Variable, pub Expr);
176
177/// An item attached to an associated container, via "::".
178/// The output will look like `Cont::Item`.
179#[derive(Clone, Debug)]
180pub struct AssociatedItem<Cont, Item>(pub Cont, pub Item);
181
182/// A question mark following another expression.
183#[derive(Clone, Debug)]
184pub struct QuestionMarkAfter<Expr>(pub Expr);
185
186/// Wraps an expression in `Ok(EXPR)`.
187#[derive(Clone, Debug)]
188pub struct OkResultOf<Expr>(pub Expr);
189
190/// Uses the `as` expression to perform a qualified trait cast (ready for a method call).
191/// I.e., this will render as `<Type as Trait>`.
192#[derive(Clone, Debug)]
193pub struct TypeAsTrait<Type, Trait>(pub Type, pub Trait);
194
195/// Declaration of an extern block, i.e. for FFI.
196/// In Rust 2024 and later, the unsafe keyword must be added for extern blocks. Thus, this struct
197/// requires that the context satisfies [ContextProvides] for [Edition].
198#[derive(Clone, Debug)]
199pub struct ExternBlock<Abi, Body> {
200 /// The ABI chosen. Must be writable
201 pub abi: Abi,
202 /// The body of the extern block. Must be writable
203 pub body: Body,
204}
205
206impl<Abi, Body> CanHaveAttributes for ExternBlock<Abi, Body> {
207 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self> {
208 WithAttributes {
209 attr,
210 separator: "\n",
211 value: self,
212 }
213 }
214}
215
216/// Places the expression inside an unsafe block.
217/// Adds new lines inside the brackets, wrapping the inner expression.
218#[derive(Clone, Debug)]
219pub struct UnsafeBlock<Expr>(pub Expr);
220
221/// Writes a closure.
222/// Adds new lines inside the brackets, wrapping the inner expression.
223#[derive(Clone, Debug)]
224pub struct Closure<InputVars, Expr> {
225 /// The input variables.
226 /// Should be a sequence. They will be comma separated and placed within the pipes.
227 /// To use no input variables, use [NoOpSeq].
228 pub input_vars: InputVars,
229 /// The expression inside the closure block.
230 pub inside_block: Expr,
231}
232
233/// Performs a call to a function inside code.
234#[derive(Clone, Debug)]
235pub struct FunctionCall<Recv, Name, Args> {
236 /// The function receiver
237 pub receiver: Recv,
238 /// Whether the function is associated, false if it's a method
239 pub is_assoc: bool,
240 /// The function name
241 pub name: Name,
242 /// The arguments. Must be a sequence
243 pub args: Args,
244}
245
246/// Provides access to the "turbofish" syntax, i.e. `Name::<Args>`.
247/// The first tuple value must be writable, and the second must be a sequence.
248///
249/// Note that if the sequence outputs nothing, this struct will behave as if no args were
250/// specified. I.e. `Turbofish(Name, NoOpSeq)` is equivalent to just `Name`.
251#[derive(Clone, Debug)]
252pub struct Turbofish<Name, Args>(pub Name, pub Args);
253
254/// A function declaration
255#[derive(Clone, Debug)]
256pub struct FunctionDef<Mods, Name, Args, Return, Where, Body> {
257 /// The modifiers. Must be a sequence.
258 pub mods: Mods,
259 /// The function name. Type variables can be declared here via [Parameterized]
260 pub name: Name,
261 /// The arguments. Must be a sequence
262 pub args: Args,
263 /// The return type, i.e. after the `->` arrow
264 pub return_type: Return,
265 /// The "where" conditions. Must be a sequence. Set to [NoOp] to disable.
266 /// Will render as `where C1, C2, C3, ...` where CX is a value in the sequence.
267 pub where_conds: Where,
268 /// The function body.
269 /// To only declare the function, this must be `;` so use [FunctionBodyDeclare]
270 /// To implement the function, use [FunctionBodyImplement]
271 pub body: Body,
272}
273
274impl<Mods, Name, Args, Return, Where, Body> CanHaveAttributes
275 for FunctionDef<Mods, Name, Args, Return, Where, Body>
276{
277 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self> {
278 WithAttributes {
279 attr,
280 separator: "\n",
281 value: self,
282 }
283 }
284}
285
286/// Declares a function body. This is equivalent to just a semicolon.
287#[derive(Clone, Debug)]
288pub struct FunctionBodyDeclare;
289
290/// Implements a function body. Places the contents inside brackets
291#[derive(Clone, Debug)]
292pub struct FunctionBodyImplement<Inner>(pub Inner);
293
294/// A function pointer. Can be used for `fn`, `Fn`, `FnMut`, and `FnOnce`.
295///
296/// Example:
297/// ```
298/// # use async_codegen::common::{SingularSeq, Str};
299/// # use async_codegen::context::EmptyContext;
300/// # use async_codegen::rust::{FunctionPtr, FunctionPtrKind};
301/// # use async_codegen::util::InMemoryOutput;
302/// let function_ptr = FunctionPtr {
303/// kind: FunctionPtrKind::FnMut,
304/// args: SingularSeq(Str("String")),
305/// return_type: Str("bool")
306/// };
307/// let string = InMemoryOutput::print_output(EmptyContext, &function_ptr);
308/// assert_eq!("FnMut(String) -> bool", string);
309/// ```
310#[derive(Clone, Debug)]
311pub struct FunctionPtr<Args, Return> {
312 /// The function pointer kind
313 pub kind: FunctionPtrKind,
314 /// The arguments. Must be a sequence
315 pub args: Args,
316 /// The return type, i.e. after the `->` arrow
317 pub return_type: Return,
318}
319
320/// The kind of function type
321#[derive(Clone, Debug)]
322pub enum FunctionPtrKind {
323 /// An `fn` pointer. E.g. `fn(String) -> bool`.
324 FnPtr,
325 /// Represents [Fn]
326 Fn,
327 /// Represents [FnMut]
328 FnMut,
329 /// Represents [FnOnce]
330 FnOnce,
331}
332
333/// Renders as `Type=Value`. Intended to be used as a type argument, to specify associated types.
334#[derive(Clone, Debug)]
335pub struct AssociatedTypeEquals<Type, Value>(pub Type, pub Value);
336
337/// Adds a "dyn " before a type expression.
338#[derive(Clone, Debug)]
339pub struct DynOf<Type>(pub Type);
340
341/// Adds a "&" before a type expression
342#[derive(Clone, Debug)]
343pub struct RefOf<Type>(pub Type);
344
345/// Adds an "impl " before a type expression
346pub struct ImplOf<Type>(pub Type);
347
348/// Adds a reference with a lifetime before a type expression, i.e. `&'<lifetime> <type>`
349#[derive(Clone, Debug)]
350pub struct LifetimedRefOf<'l, Type>(pub &'l str, pub Type);
351
352/// Declares an associated type, rendering as `type VarName = Value;`.
353/// Adds new lines before and after.
354#[derive(Clone, Debug)]
355pub struct AssociatedTypeDef<VarName, Value>(pub VarName, pub Value);
356
357/// The declaration of a trait
358#[derive(Clone, Debug)]
359pub struct TraitDef<Mods, Name, TypeVars, SuperTraits, Body> {
360 /// The trait modifiers, e.g. visibility. Must be a sequence.
361 pub mods: Mods,
362 /// The name of the trait
363 pub name: Name,
364 /// The type variables. Must be a sequence
365 pub type_variables: TypeVars,
366 /// The super traits. Must be a sequence
367 pub super_traits: SuperTraits,
368 /// The trait definition's body. Use [NoOp] if none exists.
369 pub body: Body,
370}
371
372impl<Mods, Name, TypeVars, SuperTraits, Body> CanHaveAttributes
373 for TraitDef<Mods, Name, TypeVars, SuperTraits, Body>
374{
375 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self> {
376 WithAttributes {
377 attr,
378 separator: "\n",
379 value: self,
380 }
381 }
382}
383
384/// The implementation declaration for a trait, applying to a certain receiver.
385#[derive(Clone, Debug)]
386pub struct TraitImpl<TypeVars, Trait, Recv, Where, Body> {
387 /// The type variables to use for the impl block itself. All type variables that appear later
388 /// on the trait or the receiver must be declared here, per Rust language rules.
389 ///
390 /// This field must be a sequence.
391 pub type_variables: TypeVars,
392 /// The trait being implemented
393 pub the_trait: Trait,
394 /// The receiver for which it is implemented
395 pub receiver: Recv,
396 /// The "where" conditions. Must be a sequence. Set to [NoOpSeq] to disable.
397 /// Will render as `where C1, C2, C3, ...` where CX is a value in the sequence.
398 pub where_conds: Where,
399 /// The body. Use [NoOp] if none exists.
400 pub body: Body,
401}
402
403impl<TypeVars, Trait, Recv, Where, Body> CanHaveAttributes
404 for TraitImpl<TypeVars, Trait, Recv, Where, Body>
405{
406 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self> {
407 WithAttributes {
408 attr,
409 separator: "\n",
410 value: self,
411 }
412 }
413}
414
415/// The declaration of a struct.
416#[derive(Clone, Debug)]
417pub struct StructDef<Mods, Name, Elements> {
418 /// The struct modifiers. Must be a sequence.
419 pub mods: Mods,
420 /// The kind of the struct.
421 ///
422 /// It is suggested to use either a [NamedTuple] or [StructCall]. A semicolon will be
423 /// automatically added afterward, as is needed for tuple structs, and this semicolon will not
424 /// affect structs with named fields.
425 pub kind: StructKind<Name, Elements>,
426}
427
428impl<Mods, Name, Elements> CanHaveAttributes for StructDef<Mods, Name, Elements> {
429 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self> {
430 WithAttributes {
431 attr,
432 separator: "\n",
433 value: self,
434 }
435 }
436}
437
438/// Completes the struct definition as either a named tuple or a struct with named fields.
439#[derive(Clone, Debug)]
440pub enum StructKind<Name, Elements> {
441 /// A named tuple. This will function similarly to [NamedTuple], except a semicolon will
442 /// be added afterward.
443 ///
444 /// `Name` must be writable, and `Elements` must be a writable sequence for the tuple arguments.
445 Tuple(Name, Elements),
446 /// A struct with named fields. This will function similarly to [StructCall].
447 ///
448 /// `Name` must be writable, and `Elements` must be writable sequence for the struct fields.
449 NamedFields(Name, Elements),
450}
451
452/// The construction or deconstruction of a struct.
453///
454/// When rendered, will use the format `Name { Body }`. Spaces will be added automatically.
455///
456/// This should **not** be used for tuple structs, for that see [NamedTuple].
457#[derive(Clone, Debug)]
458pub struct StructCall<Name, Body> {
459 /// The struct name. Must be writable.
460 ///
461 /// If you are declaring a struct for the first time, you can use [Parameterized] in order
462 /// to declare type variables.
463 pub name: Name,
464 /// The body. Must be writable.
465 ///
466 /// It is suggested to use [StructFields] for multiple fields, or [DeclareField] for just one.
467 pub body: Body,
468}
469
470/// Named struct fields. This will place every field on a new line with a comma afterward.
471/// It is recommended that the sequence should pass [DeclareField].
472///
473/// If you have a single field, you can skip using a sequence and just use [DeclareField] directly.
474pub struct StructFields<Fields>(pub Fields);
475
476/// Declares a single field within a struct. Renders as `Name: Value`.
477///
478/// Does not add attributes. If you want to use attributes for declaration purposes, you can use
479/// [CanHaveAttributes::with_attributes] on this field.
480pub struct DeclareField<Name, Value>(pub Name, pub Value);
481
482impl<Name, Value> CanHaveAttributes for DeclareField<Name, Value> {
483 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self> {
484 WithAttributes {
485 attr,
486 separator: "\n",
487 value: self,
488 }
489 }
490}
491
492/// A named tuple type.
493///
494/// Renders as `Name(A1, A2, A3, ...)` where AX is part of the argument sequence.
495/// If no arguments exist, will render only as `Name` (i.e., a unit struct).
496pub struct NamedTuple<Name, Args> {
497 pub name: Name,
498 pub args: Args,
499}
500
501/// An anonymous tuple type. This struct's tuple value must be a sequence.
502///
503/// Renders as `(A1, A2, A3, ...)` where AX is part of the argument sequence.
504#[derive(Clone, Debug)]
505pub struct AnonTuple<Args>(pub Args);
506
507/// The unit type, i.e. `()`
508pub type UnitType = AnonTuple<NoOpSeq>;
509
510impl AnonTuple<NoOpSeq> {
511 /// Creates
512 pub fn unit() -> Self {
513 Self(NoOpSeq)
514 }
515}
516
517/// Adds attributes to ANY item.
518///
519/// The first tuple value must be a sequence. The second must be a writable value. This struct
520/// is typically constructed via [CanHaveAttributes::with_attributes].
521///
522/// Rust attributes can be put in many places, so this enables you to add attributes to any
523/// writable item. For example, adding attributes to function parameters can be done like so:
524///
525/// ```rust
526/// # use async_codegen::common::{SingularSeq, Str};
527/// # use async_codegen::context::EmptyContext;
528/// # use async_codegen::rust::{Cfg, FunctionParam, MustUse, Target, WithAttributes, CanHaveAttributes};
529/// # use async_codegen::util::InMemoryOutput;
530///
531/// let function_param = FunctionParam(Str("conditional_param"), Str("Fd")).with_attributes(
532/// SingularSeq(Cfg(Target::Os(Str("linux"))))
533/// );
534/// let string = InMemoryOutput::print_output(EmptyContext, &function_param);
535/// assert_eq!("#[cfg(target_os = \"linux\")] conditional_param: Fd", string);
536/// ```
537#[derive(Clone, Debug)]
538pub struct WithAttributes<Attr, Value> {
539 pub attr: Attr,
540 /// The separator. Usually a space or a new line, depending on what the target value is
541 pub separator: &'static str,
542 /// The value
543 pub value: Value,
544}
545
546/// A writable that can have attributes attached to it
547pub trait CanHaveAttributes: Sized {
548 /// Adds attributes to this writable
549 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self>;
550}
551
552/// Defines an enum.
553///
554/// In order to use or refer to an enum, you can use [AssociatedItem] together with [NamedTuple]
555/// or [StructCall].
556pub struct EnumDef<Mods, Name, Entries> {
557 /// The modifiers on the type. Must be a sequence.
558 pub mods: Mods,
559 /// The name of the enum
560 pub name: Name,
561 /// The enum entries. Must be a sequence, each entry will be written on a new line with a comma
562 ///
563 /// As for the entries themselves, it is suggested to use [NamedTuple] or [StructCall]
564 /// depending on which kind of enum entry you want to create.
565 pub entries: Entries,
566}
567
568impl<Mods, Name, Entries> CanHaveAttributes for EnumDef<Mods, Name, Entries> {
569 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self> {
570 WithAttributes {
571 attr,
572 separator: "\n",
573 value: self,
574 }
575 }
576}
577
578/// A type argument-parameterized expression. Used in relation to parameterized names and their
579/// arguments. Examples: `function_name<args>`, `TypeName<'lifetime, args>`, `MyType<Assoc=Value>`.
580///
581/// If no type args exist, [NoOpSeq] should be used.
582#[derive(Clone, Debug)]
583pub struct Parameterized<Name, TypeArgs> {
584 name: Name,
585 type_args: TypeArgs,
586}
587
588impl<Name, TypeArgs> Parameterized<Name, TypeArgs> {
589 /// Initializes an instance
590 pub fn new(name: Name, type_args: TypeArgs) -> Self {
591 Self { name, type_args }
592 }
593}
594
595/// A type variable with a sequence of bounds.
596/// Will render as `TypeVar: B1 + B2 + ...`
597#[derive(Clone, Debug)]
598pub struct BoundedTypeVar<TypeVar, Bounds>(pub TypeVar, pub Bounds);
599
600/// A standalone lifetime, intended to be used as a type argument or variable
601#[derive(Clone, Debug)]
602pub struct Lifetime<'l>(pub &'l str);
603
604/// Renders an individual function parameter, `Name: Type`
605#[derive(Clone, Debug)]
606pub struct FunctionParam<Name, Type>(pub Name, pub Type);
607
608impl<Name, Type> CanHaveAttributes for FunctionParam<Name, Type> {
609 fn with_attributes<Attr>(self, attr: Attr) -> WithAttributes<Attr, Self> {
610 WithAttributes {
611 attr,
612 separator: " ",
613 value: self,
614 }
615 }
616}
617
618/// A sequence acceptor that writes attributes. Every attribute will be surrounded with "#[]"
619#[derive(Debug)]
620pub struct AttributesAccept<'o, O, Sep> {
621 inner: SurroundingSeqAccept<'o, O, Str<&'static str>, Combined<Str<&'static str>, Sep>>,
622}
623
624impl<'o, O> AttributesAccept<'o, O, Str<&'static str>> {
625 pub fn multiline(output: &'o mut O) -> Self {
626 Self::with_separator(output, "\n")
627 }
628}
629
630impl<'o, O> AttributesAccept<'o, O, Str<&'static str>> {
631 pub fn with_separator(output: &'o mut O, separator: &'static str) -> Self {
632 Self {
633 inner: SurroundingSeqAccept::new(output, Str("#["), Combined(Str("]"), Str(separator))),
634 }
635 }
636}
637
638impl<'o, O, Sep> SequenceAccept<O> for AttributesAccept<'o, O, Sep>
639where
640 O: Output,
641 Sep: Writable<O>,
642{
643 async fn accept<W: Writable<O>>(&mut self, writable: &W) -> Result<(), O::Error> {
644 self.inner.accept(writable).await
645 }
646}