pub enum TsTypeMember {
Prop {
name: String,
ty: TsType,
optional: bool,
readonly: bool,
},
Method {
name: String,
generics: Vec<String>,
params: Vec<TsParam>,
ret: TsType,
doc: Option<String>,
},
Index {
key_name: String,
key_ty: TsType,
value_ty: TsType,
},
}Expand description
One member of a TsType::Object structural type — a property (Prop)
or a method signature (Method, #1323’s own real gap: ack(): void,
retry(): void, waitUntil(promise: Promise<unknown>): void — no body,
a type-position sibling to TsObjectEntry::Method, which does carry
one). Method’s own parameters reuse TsParam directly (not a bare
Vec<TsType> the way TsType::Fn’s anonymous, positionally-numbered
parameters do) — waitUntil’s own real parameter has a real name
(promise) the printed text must show, unlike Fn’s callers, none of
which have one to show.
Variants§
Prop
Method
generics/doc added by #1357: emit_capability’s own interface
methods are genuinely generic (op<T>(...): ret;, no
monomorphisation) and doc-commented — bare generic names, matching
every other real generics-list precedent in this crate; doc
mirrors TsObjectEntry::Method.doc’s own identical field (#1337).
Both default empty/None via TsTypeMember::method’s own
existing constructor — every one of its 6 real pre-#1357 callers is
unaffected.
doc renders from exactly one of this variant’s two reachable
positions: TsDecl::Interface’s own render arm (a real, multi-line
declaration body with depth available, so it calls
render_doc_comment before a documented member’s own line — the
only place doc is honoured). A Method reached through
TsType::Object’s own inline, single-line shape (a type-position
object literal, e.g. { a: X; b(): Y }) has no line budget for a
JSDoc block at all — doc: Some(_) there is a real, debug_assert-
guarded misuse (render_type’s own TsType::Object arm), the same
“loud, not silently dropped” precedent review of #1338 already
established for render_object_entry_inline’s identical
TsObjectEntry::Method.doc case.
Index
[key_name: key_ty]: value_ty — a TypeScript index signature.
#1323’s own real gap: workers_entry.rs’s multi-param on call
dispatch casts its raw JSON args object through { [k: string]: JsonValue } before indexing it by field name — textually distinct
from the semantically-equivalent Record<string, JsonValue> (a
Named type with type arguments), which bynk-emit’s own
pre-conversion writeln! never wrote here. The one real site.
Implementations§
Source§impl TsTypeMember
impl TsTypeMember
Sourcepub fn prop(name: impl Into<String>, ty: TsType) -> Self
pub fn prop(name: impl Into<String>, ty: TsType) -> Self
name: ty — the ordinary, non-optional, non-readonly case.
Sourcepub fn optional_prop(name: impl Into<String>, ty: TsType) -> Self
pub fn optional_prop(name: impl Into<String>, ty: TsType) -> Self
name?: ty.
Sourcepub fn readonly_prop(name: impl Into<String>, ty: TsType) -> Self
pub fn readonly_prop(name: impl Into<String>, ty: TsType) -> Self
readonly name: ty.
Trait Implementations§
Source§impl Clone for TsTypeMember
impl Clone for TsTypeMember
Source§fn clone(&self) -> TsTypeMember
fn clone(&self) -> TsTypeMember
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for TsTypeMember
impl RefUnwindSafe for TsTypeMember
impl Send for TsTypeMember
impl Sync for TsTypeMember
impl Unpin for TsTypeMember
impl UnsafeUnpin for TsTypeMember
impl UnwindSafe for TsTypeMember
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the foreground set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red() and
green(), which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg():
use yansi::{Paint, Color};
painted.fg(Color::White);Set foreground color to white using white().
use yansi::Paint;
painted.white();§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self with the background set to
value.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red() and
on_green(), which have the same functionality but
are pithier.
§Example
Set background color to red using fg():
use yansi::{Paint, Color};
painted.bg(Color::Red);Set background color to red using on_red().
use yansi::Paint;
painted.on_red();§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling [Attribute] value.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold() and
underline(), which have the same functionality
but are pithier.
§Example
Make text bold using attr():
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);Make text bold using using bold().
use yansi::Paint;
painted.bold();§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi [Quirk] value.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask() and
wrap(), which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk():
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);Enable wrapping using wrap().
use yansi::Paint;
painted.wrap();§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting() due to conflicts with Vec::clear().
The clear() method will be removed in a future release.§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the [Condition] value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted only when both stdout and stderr are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);