Expand description
Wire types for the Docs v1 REST API.
Field naming follows Docs’ camelCase JSON via per-field
#[serde(rename = "...")], mirroring src/drive/types.rs and
src/drive/sheets/types.rs. Only the subset the CLI actually renders is
modelled; every unmodelled field is tolerated and dropped, so a Google
response gaining a field never breaks a parse.
Four shapes here are load-bearing and easy to get wrong:
startIndexis absent, not0, for the first element. Docs serialises proto3 JSON, which omits zero-valued integers, so every realdocuments.gethasbody.content[0](the leadingsectionBreak) with nostartIndexkey at all. Every index field is thereforeOption<i64>, read through thestart_index()/end_index()accessors. This is the direct analogue ofValueRange::valuesbeing absent-not-empty for a blank sheet.- Indices are UTF-16 code units, and
endIndexis exclusive. Not chars, not bytes. Any code deriving an index from a&strmust uses.encode_utf16().count(). The difference is invisible in ASCII and wrong the moment a document contains an emoji or a CJK astral character, so only the anchor resolver computes one — seecrate::drive::docs::anchor. - An empty message still serialises as
{}when present. AsectionBreakwith no fields set arrives as"sectionBreak": {}, so the union variants this module does not inspect are modelled asOption<serde_json::Value>:Some(Object({}))when present,Nonewhen absent, which is exactly the discriminator semantics needed. tabsandbodyare mutually exclusive. WithincludeTabsContent=truethe content lives undertabs[]and the top-levelbodyis absent; without it, onlybodyis populated. That is normalised once, inDocument::resolved_tabs, rather than at every call site.
Structs§
- Body
- A document body — the main index segment.
- Bullet
- A list-item marker.
- Document
- A document’s full structural model, from
documents.get. - Document
Tab - The document-flavoured content of a tab.
- Footer
- One page footer — same shape as
Header; Google models these as distinct message types even though the field is identical, so this mirrors that instead of aliasing. - Footnote
- One footnote body — same shape again. The footnote’s own id is the map key it is stored under, not a field on this struct.
- Header
- One page header — a segment addressed by the map key it is stored under.
- Inline
Object Element - A reference to an inline object.
- Named
Range - One named range.
- Named
Ranges - Every named range sharing one name.
- Paragraph
- A paragraph and its inline elements.
- Paragraph
Element - One inline element of a paragraph.
- Paragraph
Style - A paragraph’s style.
- Range
- An index span within one segment of one tab.
- Resolved
Segment - One header, footer or footnote segment, resolved and ready to flatten.
- Resolved
Tab - One tab’s content, with the legacy single-
bodyresponse normalised into the same shape so callers never branch on which form arrived. - Structural
Element - One structural element: exactly one of the variant fields is present, and which one is the discriminator.
- Tab
- One tab of a document.
- TabProperties
- A tab’s identity and position within the tab tree.
- Table
- A table.
- Table
Cell - One cell of a table row.
- Table
Cell Style - Read-only cell spans; other formatting remains outside the edit model.
- Table
OfContents - A table of contents.
- Table
Row - One row of a table.
- TextRun
- A run of text with uniform styling.