Skip to main content

Module types

Module types 

Source
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:

  • startIndex is absent, not 0, for the first element. Docs serialises proto3 JSON, which omits zero-valued integers, so every real documents.get has body.content[0] (the leading sectionBreak) with no startIndex key at all. Every index field is therefore Option<i64>, read through the start_index()/end_index() accessors. This is the direct analogue of ValueRange::values being absent-not-empty for a blank sheet.
  • Indices are UTF-16 code units, and endIndex is exclusive. Not chars, not bytes. Any code deriving an index from a &str must use s.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 — see crate::drive::docs::anchor.
  • An empty message still serialises as {} when present. A sectionBreak with no fields set arrives as "sectionBreak": {}, so the union variants this module does not inspect are modelled as Option<serde_json::Value>: Some(Object({})) when present, None when absent, which is exactly the discriminator semantics needed.
  • tabs and body are mutually exclusive. With includeTabsContent=true the content lives under tabs[] and the top-level body is absent; without it, only body is populated. That is normalised once, in Document::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.
DocumentTab
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.
InlineObjectElement
A reference to an inline object.
NamedRange
One named range.
NamedRanges
Every named range sharing one name.
Paragraph
A paragraph and its inline elements.
ParagraphElement
One inline element of a paragraph.
ParagraphStyle
A paragraph’s style.
Range
An index span within one segment of one tab.
ResolvedSegment
One header, footer or footnote segment, resolved and ready to flatten.
ResolvedTab
One tab’s content, with the legacy single-body response normalised into the same shape so callers never branch on which form arrived.
StructuralElement
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.
TableCell
One cell of a table row.
TableCellStyle
Read-only cell spans; other formatting remains outside the edit model.
TableOfContents
A table of contents.
TableRow
One row of a table.
TextRun
A run of text with uniform styling.