Skip to main content

TextRunProperties

Struct TextRunProperties 

Source
pub struct TextRunProperties {
    pub bold: bool,
    pub italic: bool,
    pub underline: Option<TextUnderline>,
    pub strike: Option<TextStrike>,
    pub fill: Option<Fill>,
    pub font_size_100ths_point: Option<i32>,
    pub font_family: Option<String>,
    pub hyperlink: Option<Hyperlink>,
    pub baseline_1000ths_percent: Option<i32>,
    pub highlight: Option<Color>,
    pub text_caps: Option<TextCaps>,
    pub character_spacing_100ths_point: Option<i32>,
}
Expand description

A run’s character formatting (<a:rPr>/<a:defRPr>/<a:endParaRPr>, CT_TextCharacterProperties) — this crate only ever writes/reads it as <a:rPr> (on <a:r>/<a:br>), not the other two contexts.

Not modeled: lang/altLang (spell-check locale), kern/normalizeH (kerning threshold, auto-condensing East Asian punctuation — narrow cosmetic refinements; spc/cap are modeled, see TextRunProperties::character_spacing_100ths_point/TextRunProperties::text_caps; baseline/highlight are also modeled, see TextRunProperties::baseline_1000ths_percent/TextRunProperties::highlight), hlinkMouseOver (a separate, rarely-authored hover-only link — only hlinkClick is modeled, see Hyperlink), underline’s own independent line/fill overrides (EG_TextUnderlineLine/ Fillu’s color here always follows the text’s own fill, matching most real-world usage), and ea/cs/sym (East Asian/complex-script/ symbol font overrides — latin alone is modeled, same “one font, not a per-script set” simplification word-ooxml::Run::font_family already makes).

Fields§

§bold: bool

b (<a:rPr b="1">).

§italic: bool

i.

§underline: Option<TextUnderline>

u.

§strike: Option<TextStrike>

strike.

§fill: Option<Fill>

EG_FillProperties — the run’s text color (or gradient/pattern/ image, though a flat Fill::Solid color covers the overwhelming majority of real documents). Reuses Fill directly rather than a narrower color-only field, since the schema itself allows the full fill choice here, not just <a:solidFill>.

§font_size_100ths_point: Option<i32>

sz, in hundredths of a point (ST_TextFontSize, 100.=400000 — i.e. 1pt to 4,000pt).

§font_family: Option<String>

<a:latin typeface=".."> — the run’s font family/typeface, e.g. "Calibri". Mirrors word-ooxml::Run::font_family by name for cross-crate consistency (same real-world concept).

§hyperlink: Option<Hyperlink>

<a:hlinkClick r:id=".."> (CT_Hyperlink, point 3) — a clickable hyperlink on this run. See Hyperlink’s own doc comment for why this carries an already-resolved relationship id rather than a raw URL.

§baseline_1000ths_percent: Option<i32>

baseline (ST_Percentage, thousandths of a percent) — raises (positive) or lowers (negative) the run’s glyphs relative to the baseline, real PowerPoint’s own superscript/subscript mechanism (its UI writes 30000 for superscript, -25000 for subscript). None omits the attribute (no offset). Grounded against a real fixture exercising both signs.

§highlight: Option<Color>

<a:highlight>{color}</a:highlight> — the run’s text-highlight color (like a highlighter pen), distinct from fill, which colors the glyphs themselves. None omits the element (no highlight). Grounded against a real fixture.

§text_caps: Option<TextCaps>

cap (ST_TextCapsType) — forces the run’s glyphs to render as small caps or all caps, independent of the text actually typed (unlike literally typing uppercase letters, the underlying text stays whatever case it was entered in). None omits the attribute (no forced case). Grounded against a real fixture’s slide text (cap="none", PowerPoint’s own explicit “no caps override” — distinct from omitting the attribute, though both render identically).

§character_spacing_100ths_point: Option<i32>

spc (ST_TextSpacingPoint, hundredths of a, may be negative to tighten spacing) — extra space inserted between characters. None omits the attribute (no adjustment). Grounded against a real fixture (spc="70", 0.7pt extra tracking).

Implementations§

Source§

impl TextRunProperties

Source

pub fn new() -> TextRunProperties

Examples found in repository?
examples/pptx_theme_and_metadata.rs (line 71)
19fn main() -> office_toolkit::Result<()> {
20    // A custom theme and an embedded font. `Theme`/`ColorScheme`/
21    // `FontScheme` have no `with_*` builders in this crate — only
22    // `office_default()` or plain struct literals.
23    let custom_theme = Theme {
24        name: "Custom Brand".to_string(),
25        colors: ColorScheme {
26            dark1: "1B1B1B".to_string(),
27            light1: "FFFFFF".to_string(),
28            dark2: "0A2540".to_string(),
29            light2: "F5F5F5".to_string(),
30            accent1: "0A2540".to_string(),
31            accent2: "E8622C".to_string(),
32            accent3: "2E86AB".to_string(),
33            accent4: "6FB98F".to_string(),
34            accent5: "F4A259".to_string(),
35            accent6: "8E4585".to_string(),
36            hyperlink: "1155CC".to_string(),
37            followed_hyperlink: "6B3FA0".to_string(),
38        },
39        fonts: FontScheme {
40            major_latin: "Georgia".to_string(),
41            minor_latin: "Verdana".to_string(),
42        },
43    };
44
45    // Placeholder bytes — a real .pptx would carry genuine TrueType/
46    // OpenType font data here.
47    let embedded_font = EmbeddedFont::new("Custom Sans")
48        .with_regular(vec![0u8; 16])
49        .with_bold(vec![0u8; 16]);
50
51    // A slide with no shapes at all renders as a blank page — nothing shows
52    // the custom theme actually took effect. `drawing::Color` has no
53    // scheme-relative variant yet (`<a:schemeClr>` isn't modeled, see that
54    // enum's own doc comment), so this can't reference the theme's accent1
55    // symbolically; it uses the same literal hex values the theme itself
56    // was built from, purely so the slide visibly matches the palette above.
57    let title_shape = AutoShape::new(2, "Title")
58        .with_properties(
59            ShapeProperties::new()
60                .with_transform(
61                    Transform2D::new()
62                        .with_offset(838_200, 838_200)
63                        .with_extent(6_000_000, 1_500_000),
64                )
65                .with_fill(Fill::Solid(Color::Rgb(custom_theme.colors.accent1.clone()))),
66        )
67        .with_text_body(
68            TextBody::new().with_paragraph(
69                TextParagraph::new().with_run(TextRun::text_with_properties(
70                    "Custom Brand theme — Georgia / Verdana, accent1 = #0A2540",
71                    TextRunProperties::new()
72                        .with_font_family(custom_theme.fonts.major_latin.clone())
73                        .with_font_size_points(24.0)
74                        .with_fill(Fill::Solid(Color::Rgb(custom_theme.colors.light1.clone()))),
75                )),
76            ),
77        );
78
79    let themed_presentation = Presentation::new()
80        .with_theme(custom_theme)
81        .with_embedded_font(embedded_font)
82        .with_slide(Slide::new().with_shape(Shape::AutoShape(title_shape)));
83    let theme_path = output_path("pptx_theme.pptx");
84    themed_presentation.save_to_file(&theme_path)?;
85    println!("Wrote {}", theme_path.display());
86
87    // Document metadata (docProps/core.xml, app.xml, and custom.xml).
88    let properties = DocumentProperties::new()
89        .with_title("Metadata example")
90        .with_author("Example Author")
91        .with_subject("Presentation-level features")
92        .with_custom_property(
93            "ProjectCode",
94            CustomPropertyValue::Text("PPTX-META".to_string()),
95        );
96    // Same reasoning as `title_shape` above: an empty slide would render
97    // blank, so a text shape spells out where the metadata actually lives.
98    let metadata_shape = AutoShape::new(2, "Note")
99        .with_properties(ShapeProperties::new().with_transform(Transform2D::new().with_offset(838_200, 838_200).with_extent(7_000_000, 1_000_000)))
100        .with_text_body(TextBody::new().with_paragraph(TextParagraph::new().with_run(TextRun::text(
101            "This presentation's metadata is in File > Info (title, author, subject, and a custom \"ProjectCode\" property) — not on this slide.",
102        ))));
103    let metadata_presentation = Presentation::new()
104        .with_properties(properties)
105        .with_slide(Slide::new().with_shape(Shape::AutoShape(metadata_shape)));
106    let metadata_path = output_path("pptx_metadata.pptx");
107    metadata_presentation.save_to_file(&metadata_path)?;
108    println!("Wrote {}", metadata_path.display());
109
110    Ok(())
111}
More examples
Hide additional examples
examples/pptx_text_formatting.rs (line 111)
19fn main() -> office_toolkit::Result<()> {
20    let path = output_path("pptx_text_formatting.pptx");
21
22    let spacing_shape = AutoShape::new(2, "Spacing")
23        .with_properties(
24            ShapeProperties::new().with_transform(
25                Transform2D::new()
26                    .with_offset(838_200, 838_200)
27                    .with_extent(6_000_000, 1_500_000),
28            ),
29        )
30        .with_text_body(
31            TextBody::new().with_paragraph(
32                TextParagraph::new()
33                    .with_properties(
34                        TextParagraphProperties::new()
35                            .with_line_spacing(TextSpacing::Percent(150_000))
36                            .with_space_before(TextSpacing::Points(1200))
37                            .with_indent_emu(457_200)
38                            .with_level(1),
39                    )
40                    .with_run(TextRun::text(
41                        "Indented, 150% line spacing, 12pt space before.",
42                    )),
43            ),
44        );
45
46    let bullets_shape = AutoShape::new(2, "Bullets")
47        .with_properties(
48            ShapeProperties::new().with_transform(
49                Transform2D::new()
50                    .with_offset(838_200, 838_200)
51                    .with_extent(6_000_000, 1_800_000),
52            ),
53        )
54        .with_text_body(
55            TextBody::new()
56                .with_paragraph(
57                    TextParagraph::new()
58                        .with_properties(
59                            TextParagraphProperties::new()
60                                .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61                        )
62                        .with_run(TextRun::text("Bulleted item")),
63                )
64                .with_paragraph(
65                    TextParagraph::new()
66                        .with_properties(TextParagraphProperties::new().with_bullet(
67                            BulletKind::AutoNumber {
68                                scheme: "arabicPeriod".to_string(),
69                                start_at: None,
70                            },
71                        ))
72                        .with_run(TextRun::text("Auto-numbered item")),
73                ),
74        );
75
76    let autofit_shape = AutoShape::new(2, "Autofit")
77        .with_text_box(true)
78        .with_properties(
79            ShapeProperties::new().with_transform(
80                Transform2D::new()
81                    .with_offset(838_200, 838_200)
82                    .with_extent(4_000_000, 1_000_000),
83            ),
84        )
85        .with_text_body(
86            TextBody::new()
87                .with_properties(
88                    TextBodyProperties::new()
89                        .with_autofit(TextAutofit::Shape)
90                        .with_anchor(TextAnchor::Center)
91                        .with_anchor_center(true),
92                )
93                .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94                    "This shape resizes to fit its text, centered both ways.",
95                ))),
96        );
97
98    let casing_shape = AutoShape::new(2, "Casing")
99        .with_properties(
100            ShapeProperties::new().with_transform(
101                Transform2D::new()
102                    .with_offset(838_200, 838_200)
103                    .with_extent(6_000_000, 1_500_000),
104            ),
105        )
106        .with_text_body(
107            TextBody::new().with_paragraph(
108                TextParagraph::new()
109                    .with_run(TextRun::text_with_properties(
110                        "rendered in all caps, ",
111                        TextRunProperties::new().with_text_caps(TextCaps::All),
112                    ))
113                    .with_run(TextRun::text_with_properties(
114                        "widely spaced, ",
115                        TextRunProperties::new().with_character_spacing_points(3.0),
116                    ))
117                    .with_run(TextRun::text_with_properties(
118                        "highlighted",
119                        TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120                    ))
121                    .with_run(TextRun::text_with_properties(
122                        "2",
123                        TextRunProperties::new().with_baseline_percent(30.0),
124                    )),
125            ),
126        );
127
128    let field_shape = AutoShape::new(2, "Field")
129        .with_properties(
130            ShapeProperties::new().with_transform(
131                Transform2D::new()
132                    .with_offset(838_200, 838_200)
133                    .with_extent(3_000_000, 500_000),
134            ),
135        )
136        .with_text_body(
137            TextBody::new().with_paragraph(
138                TextParagraph::new()
139                    .with_run(TextRun::text("Slide "))
140                    .with_run(TextRun::field(
141                        "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142                        Some("slidenum".to_string()),
143                        "1",
144                    )),
145            ),
146        );
147
148    let presentation = Presentation::new()
149        .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150        .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151        .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152        .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153        .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155    presentation.save_to_file(&path)?;
156    println!("Wrote {}", path.display());
157    Ok(())
158}
Source

pub fn with_bold(self, bold: bool) -> TextRunProperties

Source

pub fn with_italic(self, italic: bool) -> TextRunProperties

Source

pub fn with_underline(self, underline: TextUnderline) -> TextRunProperties

Source

pub fn with_strike(self, strike: TextStrike) -> TextRunProperties

Source

pub fn with_fill(self, fill: Fill) -> TextRunProperties

Examples found in repository?
examples/pptx_theme_and_metadata.rs (line 74)
19fn main() -> office_toolkit::Result<()> {
20    // A custom theme and an embedded font. `Theme`/`ColorScheme`/
21    // `FontScheme` have no `with_*` builders in this crate — only
22    // `office_default()` or plain struct literals.
23    let custom_theme = Theme {
24        name: "Custom Brand".to_string(),
25        colors: ColorScheme {
26            dark1: "1B1B1B".to_string(),
27            light1: "FFFFFF".to_string(),
28            dark2: "0A2540".to_string(),
29            light2: "F5F5F5".to_string(),
30            accent1: "0A2540".to_string(),
31            accent2: "E8622C".to_string(),
32            accent3: "2E86AB".to_string(),
33            accent4: "6FB98F".to_string(),
34            accent5: "F4A259".to_string(),
35            accent6: "8E4585".to_string(),
36            hyperlink: "1155CC".to_string(),
37            followed_hyperlink: "6B3FA0".to_string(),
38        },
39        fonts: FontScheme {
40            major_latin: "Georgia".to_string(),
41            minor_latin: "Verdana".to_string(),
42        },
43    };
44
45    // Placeholder bytes — a real .pptx would carry genuine TrueType/
46    // OpenType font data here.
47    let embedded_font = EmbeddedFont::new("Custom Sans")
48        .with_regular(vec![0u8; 16])
49        .with_bold(vec![0u8; 16]);
50
51    // A slide with no shapes at all renders as a blank page — nothing shows
52    // the custom theme actually took effect. `drawing::Color` has no
53    // scheme-relative variant yet (`<a:schemeClr>` isn't modeled, see that
54    // enum's own doc comment), so this can't reference the theme's accent1
55    // symbolically; it uses the same literal hex values the theme itself
56    // was built from, purely so the slide visibly matches the palette above.
57    let title_shape = AutoShape::new(2, "Title")
58        .with_properties(
59            ShapeProperties::new()
60                .with_transform(
61                    Transform2D::new()
62                        .with_offset(838_200, 838_200)
63                        .with_extent(6_000_000, 1_500_000),
64                )
65                .with_fill(Fill::Solid(Color::Rgb(custom_theme.colors.accent1.clone()))),
66        )
67        .with_text_body(
68            TextBody::new().with_paragraph(
69                TextParagraph::new().with_run(TextRun::text_with_properties(
70                    "Custom Brand theme — Georgia / Verdana, accent1 = #0A2540",
71                    TextRunProperties::new()
72                        .with_font_family(custom_theme.fonts.major_latin.clone())
73                        .with_font_size_points(24.0)
74                        .with_fill(Fill::Solid(Color::Rgb(custom_theme.colors.light1.clone()))),
75                )),
76            ),
77        );
78
79    let themed_presentation = Presentation::new()
80        .with_theme(custom_theme)
81        .with_embedded_font(embedded_font)
82        .with_slide(Slide::new().with_shape(Shape::AutoShape(title_shape)));
83    let theme_path = output_path("pptx_theme.pptx");
84    themed_presentation.save_to_file(&theme_path)?;
85    println!("Wrote {}", theme_path.display());
86
87    // Document metadata (docProps/core.xml, app.xml, and custom.xml).
88    let properties = DocumentProperties::new()
89        .with_title("Metadata example")
90        .with_author("Example Author")
91        .with_subject("Presentation-level features")
92        .with_custom_property(
93            "ProjectCode",
94            CustomPropertyValue::Text("PPTX-META".to_string()),
95        );
96    // Same reasoning as `title_shape` above: an empty slide would render
97    // blank, so a text shape spells out where the metadata actually lives.
98    let metadata_shape = AutoShape::new(2, "Note")
99        .with_properties(ShapeProperties::new().with_transform(Transform2D::new().with_offset(838_200, 838_200).with_extent(7_000_000, 1_000_000)))
100        .with_text_body(TextBody::new().with_paragraph(TextParagraph::new().with_run(TextRun::text(
101            "This presentation's metadata is in File > Info (title, author, subject, and a custom \"ProjectCode\" property) — not on this slide.",
102        ))));
103    let metadata_presentation = Presentation::new()
104        .with_properties(properties)
105        .with_slide(Slide::new().with_shape(Shape::AutoShape(metadata_shape)));
106    let metadata_path = output_path("pptx_metadata.pptx");
107    metadata_presentation.save_to_file(&metadata_path)?;
108    println!("Wrote {}", metadata_path.display());
109
110    Ok(())
111}
Source

pub fn with_font_size_points(self, points: f64) -> TextRunProperties

Sets the font size, given in ordinary points (converted to the schema’s hundredths-of-a-point unit internally).

Examples found in repository?
examples/pptx_theme_and_metadata.rs (line 73)
19fn main() -> office_toolkit::Result<()> {
20    // A custom theme and an embedded font. `Theme`/`ColorScheme`/
21    // `FontScheme` have no `with_*` builders in this crate — only
22    // `office_default()` or plain struct literals.
23    let custom_theme = Theme {
24        name: "Custom Brand".to_string(),
25        colors: ColorScheme {
26            dark1: "1B1B1B".to_string(),
27            light1: "FFFFFF".to_string(),
28            dark2: "0A2540".to_string(),
29            light2: "F5F5F5".to_string(),
30            accent1: "0A2540".to_string(),
31            accent2: "E8622C".to_string(),
32            accent3: "2E86AB".to_string(),
33            accent4: "6FB98F".to_string(),
34            accent5: "F4A259".to_string(),
35            accent6: "8E4585".to_string(),
36            hyperlink: "1155CC".to_string(),
37            followed_hyperlink: "6B3FA0".to_string(),
38        },
39        fonts: FontScheme {
40            major_latin: "Georgia".to_string(),
41            minor_latin: "Verdana".to_string(),
42        },
43    };
44
45    // Placeholder bytes — a real .pptx would carry genuine TrueType/
46    // OpenType font data here.
47    let embedded_font = EmbeddedFont::new("Custom Sans")
48        .with_regular(vec![0u8; 16])
49        .with_bold(vec![0u8; 16]);
50
51    // A slide with no shapes at all renders as a blank page — nothing shows
52    // the custom theme actually took effect. `drawing::Color` has no
53    // scheme-relative variant yet (`<a:schemeClr>` isn't modeled, see that
54    // enum's own doc comment), so this can't reference the theme's accent1
55    // symbolically; it uses the same literal hex values the theme itself
56    // was built from, purely so the slide visibly matches the palette above.
57    let title_shape = AutoShape::new(2, "Title")
58        .with_properties(
59            ShapeProperties::new()
60                .with_transform(
61                    Transform2D::new()
62                        .with_offset(838_200, 838_200)
63                        .with_extent(6_000_000, 1_500_000),
64                )
65                .with_fill(Fill::Solid(Color::Rgb(custom_theme.colors.accent1.clone()))),
66        )
67        .with_text_body(
68            TextBody::new().with_paragraph(
69                TextParagraph::new().with_run(TextRun::text_with_properties(
70                    "Custom Brand theme — Georgia / Verdana, accent1 = #0A2540",
71                    TextRunProperties::new()
72                        .with_font_family(custom_theme.fonts.major_latin.clone())
73                        .with_font_size_points(24.0)
74                        .with_fill(Fill::Solid(Color::Rgb(custom_theme.colors.light1.clone()))),
75                )),
76            ),
77        );
78
79    let themed_presentation = Presentation::new()
80        .with_theme(custom_theme)
81        .with_embedded_font(embedded_font)
82        .with_slide(Slide::new().with_shape(Shape::AutoShape(title_shape)));
83    let theme_path = output_path("pptx_theme.pptx");
84    themed_presentation.save_to_file(&theme_path)?;
85    println!("Wrote {}", theme_path.display());
86
87    // Document metadata (docProps/core.xml, app.xml, and custom.xml).
88    let properties = DocumentProperties::new()
89        .with_title("Metadata example")
90        .with_author("Example Author")
91        .with_subject("Presentation-level features")
92        .with_custom_property(
93            "ProjectCode",
94            CustomPropertyValue::Text("PPTX-META".to_string()),
95        );
96    // Same reasoning as `title_shape` above: an empty slide would render
97    // blank, so a text shape spells out where the metadata actually lives.
98    let metadata_shape = AutoShape::new(2, "Note")
99        .with_properties(ShapeProperties::new().with_transform(Transform2D::new().with_offset(838_200, 838_200).with_extent(7_000_000, 1_000_000)))
100        .with_text_body(TextBody::new().with_paragraph(TextParagraph::new().with_run(TextRun::text(
101            "This presentation's metadata is in File > Info (title, author, subject, and a custom \"ProjectCode\" property) — not on this slide.",
102        ))));
103    let metadata_presentation = Presentation::new()
104        .with_properties(properties)
105        .with_slide(Slide::new().with_shape(Shape::AutoShape(metadata_shape)));
106    let metadata_path = output_path("pptx_metadata.pptx");
107    metadata_presentation.save_to_file(&metadata_path)?;
108    println!("Wrote {}", metadata_path.display());
109
110    Ok(())
111}
Source

pub fn with_font_family( self, font_family: impl Into<String>, ) -> TextRunProperties

Examples found in repository?
examples/pptx_theme_and_metadata.rs (line 72)
19fn main() -> office_toolkit::Result<()> {
20    // A custom theme and an embedded font. `Theme`/`ColorScheme`/
21    // `FontScheme` have no `with_*` builders in this crate — only
22    // `office_default()` or plain struct literals.
23    let custom_theme = Theme {
24        name: "Custom Brand".to_string(),
25        colors: ColorScheme {
26            dark1: "1B1B1B".to_string(),
27            light1: "FFFFFF".to_string(),
28            dark2: "0A2540".to_string(),
29            light2: "F5F5F5".to_string(),
30            accent1: "0A2540".to_string(),
31            accent2: "E8622C".to_string(),
32            accent3: "2E86AB".to_string(),
33            accent4: "6FB98F".to_string(),
34            accent5: "F4A259".to_string(),
35            accent6: "8E4585".to_string(),
36            hyperlink: "1155CC".to_string(),
37            followed_hyperlink: "6B3FA0".to_string(),
38        },
39        fonts: FontScheme {
40            major_latin: "Georgia".to_string(),
41            minor_latin: "Verdana".to_string(),
42        },
43    };
44
45    // Placeholder bytes — a real .pptx would carry genuine TrueType/
46    // OpenType font data here.
47    let embedded_font = EmbeddedFont::new("Custom Sans")
48        .with_regular(vec![0u8; 16])
49        .with_bold(vec![0u8; 16]);
50
51    // A slide with no shapes at all renders as a blank page — nothing shows
52    // the custom theme actually took effect. `drawing::Color` has no
53    // scheme-relative variant yet (`<a:schemeClr>` isn't modeled, see that
54    // enum's own doc comment), so this can't reference the theme's accent1
55    // symbolically; it uses the same literal hex values the theme itself
56    // was built from, purely so the slide visibly matches the palette above.
57    let title_shape = AutoShape::new(2, "Title")
58        .with_properties(
59            ShapeProperties::new()
60                .with_transform(
61                    Transform2D::new()
62                        .with_offset(838_200, 838_200)
63                        .with_extent(6_000_000, 1_500_000),
64                )
65                .with_fill(Fill::Solid(Color::Rgb(custom_theme.colors.accent1.clone()))),
66        )
67        .with_text_body(
68            TextBody::new().with_paragraph(
69                TextParagraph::new().with_run(TextRun::text_with_properties(
70                    "Custom Brand theme — Georgia / Verdana, accent1 = #0A2540",
71                    TextRunProperties::new()
72                        .with_font_family(custom_theme.fonts.major_latin.clone())
73                        .with_font_size_points(24.0)
74                        .with_fill(Fill::Solid(Color::Rgb(custom_theme.colors.light1.clone()))),
75                )),
76            ),
77        );
78
79    let themed_presentation = Presentation::new()
80        .with_theme(custom_theme)
81        .with_embedded_font(embedded_font)
82        .with_slide(Slide::new().with_shape(Shape::AutoShape(title_shape)));
83    let theme_path = output_path("pptx_theme.pptx");
84    themed_presentation.save_to_file(&theme_path)?;
85    println!("Wrote {}", theme_path.display());
86
87    // Document metadata (docProps/core.xml, app.xml, and custom.xml).
88    let properties = DocumentProperties::new()
89        .with_title("Metadata example")
90        .with_author("Example Author")
91        .with_subject("Presentation-level features")
92        .with_custom_property(
93            "ProjectCode",
94            CustomPropertyValue::Text("PPTX-META".to_string()),
95        );
96    // Same reasoning as `title_shape` above: an empty slide would render
97    // blank, so a text shape spells out where the metadata actually lives.
98    let metadata_shape = AutoShape::new(2, "Note")
99        .with_properties(ShapeProperties::new().with_transform(Transform2D::new().with_offset(838_200, 838_200).with_extent(7_000_000, 1_000_000)))
100        .with_text_body(TextBody::new().with_paragraph(TextParagraph::new().with_run(TextRun::text(
101            "This presentation's metadata is in File > Info (title, author, subject, and a custom \"ProjectCode\" property) — not on this slide.",
102        ))));
103    let metadata_presentation = Presentation::new()
104        .with_properties(properties)
105        .with_slide(Slide::new().with_shape(Shape::AutoShape(metadata_shape)));
106    let metadata_path = output_path("pptx_metadata.pptx");
107    metadata_presentation.save_to_file(&metadata_path)?;
108    println!("Wrote {}", metadata_path.display());
109
110    Ok(())
111}

Attaches a hyperlink to this run.

Source

pub fn with_baseline_percent(self, percent: f64) -> TextRunProperties

Sets the run’s baseline offset (superscript/subscript), given as an ordinary percentage (e.g. 30.0 for real PowerPoint’s own superscript, -25.0 for its subscript).

Examples found in repository?
examples/pptx_text_formatting.rs (line 123)
19fn main() -> office_toolkit::Result<()> {
20    let path = output_path("pptx_text_formatting.pptx");
21
22    let spacing_shape = AutoShape::new(2, "Spacing")
23        .with_properties(
24            ShapeProperties::new().with_transform(
25                Transform2D::new()
26                    .with_offset(838_200, 838_200)
27                    .with_extent(6_000_000, 1_500_000),
28            ),
29        )
30        .with_text_body(
31            TextBody::new().with_paragraph(
32                TextParagraph::new()
33                    .with_properties(
34                        TextParagraphProperties::new()
35                            .with_line_spacing(TextSpacing::Percent(150_000))
36                            .with_space_before(TextSpacing::Points(1200))
37                            .with_indent_emu(457_200)
38                            .with_level(1),
39                    )
40                    .with_run(TextRun::text(
41                        "Indented, 150% line spacing, 12pt space before.",
42                    )),
43            ),
44        );
45
46    let bullets_shape = AutoShape::new(2, "Bullets")
47        .with_properties(
48            ShapeProperties::new().with_transform(
49                Transform2D::new()
50                    .with_offset(838_200, 838_200)
51                    .with_extent(6_000_000, 1_800_000),
52            ),
53        )
54        .with_text_body(
55            TextBody::new()
56                .with_paragraph(
57                    TextParagraph::new()
58                        .with_properties(
59                            TextParagraphProperties::new()
60                                .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61                        )
62                        .with_run(TextRun::text("Bulleted item")),
63                )
64                .with_paragraph(
65                    TextParagraph::new()
66                        .with_properties(TextParagraphProperties::new().with_bullet(
67                            BulletKind::AutoNumber {
68                                scheme: "arabicPeriod".to_string(),
69                                start_at: None,
70                            },
71                        ))
72                        .with_run(TextRun::text("Auto-numbered item")),
73                ),
74        );
75
76    let autofit_shape = AutoShape::new(2, "Autofit")
77        .with_text_box(true)
78        .with_properties(
79            ShapeProperties::new().with_transform(
80                Transform2D::new()
81                    .with_offset(838_200, 838_200)
82                    .with_extent(4_000_000, 1_000_000),
83            ),
84        )
85        .with_text_body(
86            TextBody::new()
87                .with_properties(
88                    TextBodyProperties::new()
89                        .with_autofit(TextAutofit::Shape)
90                        .with_anchor(TextAnchor::Center)
91                        .with_anchor_center(true),
92                )
93                .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94                    "This shape resizes to fit its text, centered both ways.",
95                ))),
96        );
97
98    let casing_shape = AutoShape::new(2, "Casing")
99        .with_properties(
100            ShapeProperties::new().with_transform(
101                Transform2D::new()
102                    .with_offset(838_200, 838_200)
103                    .with_extent(6_000_000, 1_500_000),
104            ),
105        )
106        .with_text_body(
107            TextBody::new().with_paragraph(
108                TextParagraph::new()
109                    .with_run(TextRun::text_with_properties(
110                        "rendered in all caps, ",
111                        TextRunProperties::new().with_text_caps(TextCaps::All),
112                    ))
113                    .with_run(TextRun::text_with_properties(
114                        "widely spaced, ",
115                        TextRunProperties::new().with_character_spacing_points(3.0),
116                    ))
117                    .with_run(TextRun::text_with_properties(
118                        "highlighted",
119                        TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120                    ))
121                    .with_run(TextRun::text_with_properties(
122                        "2",
123                        TextRunProperties::new().with_baseline_percent(30.0),
124                    )),
125            ),
126        );
127
128    let field_shape = AutoShape::new(2, "Field")
129        .with_properties(
130            ShapeProperties::new().with_transform(
131                Transform2D::new()
132                    .with_offset(838_200, 838_200)
133                    .with_extent(3_000_000, 500_000),
134            ),
135        )
136        .with_text_body(
137            TextBody::new().with_paragraph(
138                TextParagraph::new()
139                    .with_run(TextRun::text("Slide "))
140                    .with_run(TextRun::field(
141                        "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142                        Some("slidenum".to_string()),
143                        "1",
144                    )),
145            ),
146        );
147
148    let presentation = Presentation::new()
149        .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150        .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151        .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152        .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153        .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155    presentation.save_to_file(&path)?;
156    println!("Wrote {}", path.display());
157    Ok(())
158}
Source

pub fn with_highlight(self, color: Color) -> TextRunProperties

Sets the run’s text-highlight color.

Examples found in repository?
examples/pptx_text_formatting.rs (line 119)
19fn main() -> office_toolkit::Result<()> {
20    let path = output_path("pptx_text_formatting.pptx");
21
22    let spacing_shape = AutoShape::new(2, "Spacing")
23        .with_properties(
24            ShapeProperties::new().with_transform(
25                Transform2D::new()
26                    .with_offset(838_200, 838_200)
27                    .with_extent(6_000_000, 1_500_000),
28            ),
29        )
30        .with_text_body(
31            TextBody::new().with_paragraph(
32                TextParagraph::new()
33                    .with_properties(
34                        TextParagraphProperties::new()
35                            .with_line_spacing(TextSpacing::Percent(150_000))
36                            .with_space_before(TextSpacing::Points(1200))
37                            .with_indent_emu(457_200)
38                            .with_level(1),
39                    )
40                    .with_run(TextRun::text(
41                        "Indented, 150% line spacing, 12pt space before.",
42                    )),
43            ),
44        );
45
46    let bullets_shape = AutoShape::new(2, "Bullets")
47        .with_properties(
48            ShapeProperties::new().with_transform(
49                Transform2D::new()
50                    .with_offset(838_200, 838_200)
51                    .with_extent(6_000_000, 1_800_000),
52            ),
53        )
54        .with_text_body(
55            TextBody::new()
56                .with_paragraph(
57                    TextParagraph::new()
58                        .with_properties(
59                            TextParagraphProperties::new()
60                                .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61                        )
62                        .with_run(TextRun::text("Bulleted item")),
63                )
64                .with_paragraph(
65                    TextParagraph::new()
66                        .with_properties(TextParagraphProperties::new().with_bullet(
67                            BulletKind::AutoNumber {
68                                scheme: "arabicPeriod".to_string(),
69                                start_at: None,
70                            },
71                        ))
72                        .with_run(TextRun::text("Auto-numbered item")),
73                ),
74        );
75
76    let autofit_shape = AutoShape::new(2, "Autofit")
77        .with_text_box(true)
78        .with_properties(
79            ShapeProperties::new().with_transform(
80                Transform2D::new()
81                    .with_offset(838_200, 838_200)
82                    .with_extent(4_000_000, 1_000_000),
83            ),
84        )
85        .with_text_body(
86            TextBody::new()
87                .with_properties(
88                    TextBodyProperties::new()
89                        .with_autofit(TextAutofit::Shape)
90                        .with_anchor(TextAnchor::Center)
91                        .with_anchor_center(true),
92                )
93                .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94                    "This shape resizes to fit its text, centered both ways.",
95                ))),
96        );
97
98    let casing_shape = AutoShape::new(2, "Casing")
99        .with_properties(
100            ShapeProperties::new().with_transform(
101                Transform2D::new()
102                    .with_offset(838_200, 838_200)
103                    .with_extent(6_000_000, 1_500_000),
104            ),
105        )
106        .with_text_body(
107            TextBody::new().with_paragraph(
108                TextParagraph::new()
109                    .with_run(TextRun::text_with_properties(
110                        "rendered in all caps, ",
111                        TextRunProperties::new().with_text_caps(TextCaps::All),
112                    ))
113                    .with_run(TextRun::text_with_properties(
114                        "widely spaced, ",
115                        TextRunProperties::new().with_character_spacing_points(3.0),
116                    ))
117                    .with_run(TextRun::text_with_properties(
118                        "highlighted",
119                        TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120                    ))
121                    .with_run(TextRun::text_with_properties(
122                        "2",
123                        TextRunProperties::new().with_baseline_percent(30.0),
124                    )),
125            ),
126        );
127
128    let field_shape = AutoShape::new(2, "Field")
129        .with_properties(
130            ShapeProperties::new().with_transform(
131                Transform2D::new()
132                    .with_offset(838_200, 838_200)
133                    .with_extent(3_000_000, 500_000),
134            ),
135        )
136        .with_text_body(
137            TextBody::new().with_paragraph(
138                TextParagraph::new()
139                    .with_run(TextRun::text("Slide "))
140                    .with_run(TextRun::field(
141                        "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142                        Some("slidenum".to_string()),
143                        "1",
144                    )),
145            ),
146        );
147
148    let presentation = Presentation::new()
149        .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150        .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151        .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152        .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153        .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155    presentation.save_to_file(&path)?;
156    println!("Wrote {}", path.display());
157    Ok(())
158}
Source

pub fn with_text_caps(self, caps: TextCaps) -> TextRunProperties

Sets the run’s forced letter case (small caps/all caps).

Examples found in repository?
examples/pptx_text_formatting.rs (line 111)
19fn main() -> office_toolkit::Result<()> {
20    let path = output_path("pptx_text_formatting.pptx");
21
22    let spacing_shape = AutoShape::new(2, "Spacing")
23        .with_properties(
24            ShapeProperties::new().with_transform(
25                Transform2D::new()
26                    .with_offset(838_200, 838_200)
27                    .with_extent(6_000_000, 1_500_000),
28            ),
29        )
30        .with_text_body(
31            TextBody::new().with_paragraph(
32                TextParagraph::new()
33                    .with_properties(
34                        TextParagraphProperties::new()
35                            .with_line_spacing(TextSpacing::Percent(150_000))
36                            .with_space_before(TextSpacing::Points(1200))
37                            .with_indent_emu(457_200)
38                            .with_level(1),
39                    )
40                    .with_run(TextRun::text(
41                        "Indented, 150% line spacing, 12pt space before.",
42                    )),
43            ),
44        );
45
46    let bullets_shape = AutoShape::new(2, "Bullets")
47        .with_properties(
48            ShapeProperties::new().with_transform(
49                Transform2D::new()
50                    .with_offset(838_200, 838_200)
51                    .with_extent(6_000_000, 1_800_000),
52            ),
53        )
54        .with_text_body(
55            TextBody::new()
56                .with_paragraph(
57                    TextParagraph::new()
58                        .with_properties(
59                            TextParagraphProperties::new()
60                                .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61                        )
62                        .with_run(TextRun::text("Bulleted item")),
63                )
64                .with_paragraph(
65                    TextParagraph::new()
66                        .with_properties(TextParagraphProperties::new().with_bullet(
67                            BulletKind::AutoNumber {
68                                scheme: "arabicPeriod".to_string(),
69                                start_at: None,
70                            },
71                        ))
72                        .with_run(TextRun::text("Auto-numbered item")),
73                ),
74        );
75
76    let autofit_shape = AutoShape::new(2, "Autofit")
77        .with_text_box(true)
78        .with_properties(
79            ShapeProperties::new().with_transform(
80                Transform2D::new()
81                    .with_offset(838_200, 838_200)
82                    .with_extent(4_000_000, 1_000_000),
83            ),
84        )
85        .with_text_body(
86            TextBody::new()
87                .with_properties(
88                    TextBodyProperties::new()
89                        .with_autofit(TextAutofit::Shape)
90                        .with_anchor(TextAnchor::Center)
91                        .with_anchor_center(true),
92                )
93                .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94                    "This shape resizes to fit its text, centered both ways.",
95                ))),
96        );
97
98    let casing_shape = AutoShape::new(2, "Casing")
99        .with_properties(
100            ShapeProperties::new().with_transform(
101                Transform2D::new()
102                    .with_offset(838_200, 838_200)
103                    .with_extent(6_000_000, 1_500_000),
104            ),
105        )
106        .with_text_body(
107            TextBody::new().with_paragraph(
108                TextParagraph::new()
109                    .with_run(TextRun::text_with_properties(
110                        "rendered in all caps, ",
111                        TextRunProperties::new().with_text_caps(TextCaps::All),
112                    ))
113                    .with_run(TextRun::text_with_properties(
114                        "widely spaced, ",
115                        TextRunProperties::new().with_character_spacing_points(3.0),
116                    ))
117                    .with_run(TextRun::text_with_properties(
118                        "highlighted",
119                        TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120                    ))
121                    .with_run(TextRun::text_with_properties(
122                        "2",
123                        TextRunProperties::new().with_baseline_percent(30.0),
124                    )),
125            ),
126        );
127
128    let field_shape = AutoShape::new(2, "Field")
129        .with_properties(
130            ShapeProperties::new().with_transform(
131                Transform2D::new()
132                    .with_offset(838_200, 838_200)
133                    .with_extent(3_000_000, 500_000),
134            ),
135        )
136        .with_text_body(
137            TextBody::new().with_paragraph(
138                TextParagraph::new()
139                    .with_run(TextRun::text("Slide "))
140                    .with_run(TextRun::field(
141                        "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142                        Some("slidenum".to_string()),
143                        "1",
144                    )),
145            ),
146        );
147
148    let presentation = Presentation::new()
149        .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150        .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151        .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152        .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153        .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155    presentation.save_to_file(&path)?;
156    println!("Wrote {}", path.display());
157    Ok(())
158}
Source

pub fn with_character_spacing_points(self, points: f64) -> TextRunProperties

Sets the run’s extra inter-character spacing, given in ordinary points (converted to the schema’s hundredths-of-a-point unit internally; negative tightens spacing).

Examples found in repository?
examples/pptx_text_formatting.rs (line 115)
19fn main() -> office_toolkit::Result<()> {
20    let path = output_path("pptx_text_formatting.pptx");
21
22    let spacing_shape = AutoShape::new(2, "Spacing")
23        .with_properties(
24            ShapeProperties::new().with_transform(
25                Transform2D::new()
26                    .with_offset(838_200, 838_200)
27                    .with_extent(6_000_000, 1_500_000),
28            ),
29        )
30        .with_text_body(
31            TextBody::new().with_paragraph(
32                TextParagraph::new()
33                    .with_properties(
34                        TextParagraphProperties::new()
35                            .with_line_spacing(TextSpacing::Percent(150_000))
36                            .with_space_before(TextSpacing::Points(1200))
37                            .with_indent_emu(457_200)
38                            .with_level(1),
39                    )
40                    .with_run(TextRun::text(
41                        "Indented, 150% line spacing, 12pt space before.",
42                    )),
43            ),
44        );
45
46    let bullets_shape = AutoShape::new(2, "Bullets")
47        .with_properties(
48            ShapeProperties::new().with_transform(
49                Transform2D::new()
50                    .with_offset(838_200, 838_200)
51                    .with_extent(6_000_000, 1_800_000),
52            ),
53        )
54        .with_text_body(
55            TextBody::new()
56                .with_paragraph(
57                    TextParagraph::new()
58                        .with_properties(
59                            TextParagraphProperties::new()
60                                .with_bullet(BulletKind::Character("\u{2022}".to_string())),
61                        )
62                        .with_run(TextRun::text("Bulleted item")),
63                )
64                .with_paragraph(
65                    TextParagraph::new()
66                        .with_properties(TextParagraphProperties::new().with_bullet(
67                            BulletKind::AutoNumber {
68                                scheme: "arabicPeriod".to_string(),
69                                start_at: None,
70                            },
71                        ))
72                        .with_run(TextRun::text("Auto-numbered item")),
73                ),
74        );
75
76    let autofit_shape = AutoShape::new(2, "Autofit")
77        .with_text_box(true)
78        .with_properties(
79            ShapeProperties::new().with_transform(
80                Transform2D::new()
81                    .with_offset(838_200, 838_200)
82                    .with_extent(4_000_000, 1_000_000),
83            ),
84        )
85        .with_text_body(
86            TextBody::new()
87                .with_properties(
88                    TextBodyProperties::new()
89                        .with_autofit(TextAutofit::Shape)
90                        .with_anchor(TextAnchor::Center)
91                        .with_anchor_center(true),
92                )
93                .with_paragraph(TextParagraph::new().with_run(TextRun::text(
94                    "This shape resizes to fit its text, centered both ways.",
95                ))),
96        );
97
98    let casing_shape = AutoShape::new(2, "Casing")
99        .with_properties(
100            ShapeProperties::new().with_transform(
101                Transform2D::new()
102                    .with_offset(838_200, 838_200)
103                    .with_extent(6_000_000, 1_500_000),
104            ),
105        )
106        .with_text_body(
107            TextBody::new().with_paragraph(
108                TextParagraph::new()
109                    .with_run(TextRun::text_with_properties(
110                        "rendered in all caps, ",
111                        TextRunProperties::new().with_text_caps(TextCaps::All),
112                    ))
113                    .with_run(TextRun::text_with_properties(
114                        "widely spaced, ",
115                        TextRunProperties::new().with_character_spacing_points(3.0),
116                    ))
117                    .with_run(TextRun::text_with_properties(
118                        "highlighted",
119                        TextRunProperties::new().with_highlight(Color::Rgb("FFFF00".to_string())),
120                    ))
121                    .with_run(TextRun::text_with_properties(
122                        "2",
123                        TextRunProperties::new().with_baseline_percent(30.0),
124                    )),
125            ),
126        );
127
128    let field_shape = AutoShape::new(2, "Field")
129        .with_properties(
130            ShapeProperties::new().with_transform(
131                Transform2D::new()
132                    .with_offset(838_200, 838_200)
133                    .with_extent(3_000_000, 500_000),
134            ),
135        )
136        .with_text_body(
137            TextBody::new().with_paragraph(
138                TextParagraph::new()
139                    .with_run(TextRun::text("Slide "))
140                    .with_run(TextRun::field(
141                        "{7A9E3F10-4B6C-4D2E-9A1F-8C5D6E7F0123}",
142                        Some("slidenum".to_string()),
143                        "1",
144                    )),
145            ),
146        );
147
148    let presentation = Presentation::new()
149        .with_slide(Slide::new().with_shape(Shape::AutoShape(spacing_shape)))
150        .with_slide(Slide::new().with_shape(Shape::AutoShape(bullets_shape)))
151        .with_slide(Slide::new().with_shape(Shape::AutoShape(autofit_shape)))
152        .with_slide(Slide::new().with_shape(Shape::AutoShape(casing_shape)))
153        .with_slide(Slide::new().with_shape(Shape::AutoShape(field_shape)));
154
155    presentation.save_to_file(&path)?;
156    println!("Wrote {}", path.display());
157    Ok(())
158}

Trait Implementations§

Source§

impl Clone for TextRunProperties

Source§

fn clone(&self) -> TextRunProperties

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for TextRunProperties

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error>

Formats the value using the given formatter. Read more
Source§

impl Default for TextRunProperties

Source§

fn default() -> TextRunProperties

Returns the “default value” for a type. Read more
Source§

impl PartialEq for TextRunProperties

Source§

fn eq(&self, other: &TextRunProperties) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TextRunProperties

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.