Document

Struct Document 

Source
#[non_exhaustive]
pub struct Document {
Show 17 fields pub docid: String, pub mime_type: String, pub text: String, pub text_styles: Vec<Style>, pub pages: Vec<Page>, pub entities: Vec<Entity>, pub entity_relations: Vec<EntityRelation>, pub text_changes: Vec<TextChange>, pub shard_info: Option<ShardInfo>, pub error: Option<Status>, pub revisions: Vec<Revision>, pub document_layout: Option<DocumentLayout>, pub chunked_document: Option<ChunkedDocument>, pub entity_validation_output: Option<EntityValidationOutput>, pub entities_revisions: Vec<EntitiesRevision>, pub entities_revision_id: String, pub source: Option<Source>, /* private fields */
}
Expand description

Document represents the canonical document resource in Document AI. It is an interchange format that provides insights into documents and allows for collaboration between users and Document AI to iterate and optimize for quality.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§docid: String

Optional. An internal identifier for document. Should be loggable (no PII).

§mime_type: String

An IANA published media type (MIME type).

§text: String

Optional. UTF-8 encoded text in reading order from the document.

§text_styles: Vec<Style>
👎Deprecated

Styles for the Document.text.

§pages: Vec<Page>

Visual page layout for the Document.

§entities: Vec<Entity>

A list of entities detected on Document.text. For document shards, entities in this list may cross shard boundaries.

§entity_relations: Vec<EntityRelation>

Placeholder. Relationship among Document.entities.

§text_changes: Vec<TextChange>

Placeholder. A list of text corrections made to Document.text. This is usually used for annotating corrections to OCR mistakes. Text changes for a given revision may not overlap with each other.

§shard_info: Option<ShardInfo>

Information about the sharding if this document is sharded part of a larger document. If the document is not sharded, this message is not specified.

§error: Option<Status>

Any error that occurred while processing this document.

§revisions: Vec<Revision>

Placeholder. Revision history of this document.

§document_layout: Option<DocumentLayout>

Parsed layout of the document.

§chunked_document: Option<ChunkedDocument>

Document chunked based on chunking config.

§entity_validation_output: Option<EntityValidationOutput>

The entity validation output for the document. This is the validation output for document.entities field.

§entities_revisions: Vec<EntitiesRevision>

A list of entity revisions. The entity revisions are appended to the document in the processing order. This field can be used for comparing the entity extraction results at different stages of the processing.

§entities_revision_id: String

The entity revision id that document.entities field is based on. If this field is set and entities_revisions is not empty, the entities in document.entities field are the entities in the entity revision with this id and document.entity_validation_output field is the entity_validation_output field in this entity revision.

§source: Option<Source>

Original source document from the user.

Implementations§

Source§

impl Document

Source

pub fn new() -> Self

Source

pub fn set_docid<T: Into<String>>(self, v: T) -> Self

Sets the value of docid.

§Example
let x = Document::new().set_docid("example");
Source

pub fn set_mime_type<T: Into<String>>(self, v: T) -> Self

Sets the value of mime_type.

§Example
let x = Document::new().set_mime_type("example");
Source

pub fn set_text<T: Into<String>>(self, v: T) -> Self

Sets the value of text.

§Example
let x = Document::new().set_text("example");
Source

pub fn set_text_styles<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<Style>,

👎Deprecated

Sets the value of text_styles.

§Example
use google_cloud_documentai_v1::model::document::Style;
let x = Document::new()
    .set_text_styles([
        Style::default()/* use setters */,
        Style::default()/* use (different) setters */,
    ]);
Source

pub fn set_pages<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<Page>,

Sets the value of pages.

§Example
use google_cloud_documentai_v1::model::document::Page;
let x = Document::new()
    .set_pages([
        Page::default()/* use setters */,
        Page::default()/* use (different) setters */,
    ]);
Source

pub fn set_entities<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<Entity>,

Sets the value of entities.

§Example
use google_cloud_documentai_v1::model::document::Entity;
let x = Document::new()
    .set_entities([
        Entity::default()/* use setters */,
        Entity::default()/* use (different) setters */,
    ]);
Source

pub fn set_entity_relations<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<EntityRelation>,

Sets the value of entity_relations.

§Example
use google_cloud_documentai_v1::model::document::EntityRelation;
let x = Document::new()
    .set_entity_relations([
        EntityRelation::default()/* use setters */,
        EntityRelation::default()/* use (different) setters */,
    ]);
Source

pub fn set_text_changes<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<TextChange>,

Sets the value of text_changes.

§Example
use google_cloud_documentai_v1::model::document::TextChange;
let x = Document::new()
    .set_text_changes([
        TextChange::default()/* use setters */,
        TextChange::default()/* use (different) setters */,
    ]);
Source

pub fn set_shard_info<T>(self, v: T) -> Self
where T: Into<ShardInfo>,

Sets the value of shard_info.

§Example
use google_cloud_documentai_v1::model::document::ShardInfo;
let x = Document::new().set_shard_info(ShardInfo::default()/* use setters */);
Source

pub fn set_or_clear_shard_info<T>(self, v: Option<T>) -> Self
where T: Into<ShardInfo>,

Sets or clears the value of shard_info.

§Example
use google_cloud_documentai_v1::model::document::ShardInfo;
let x = Document::new().set_or_clear_shard_info(Some(ShardInfo::default()/* use setters */));
let x = Document::new().set_or_clear_shard_info(None::<ShardInfo>);
Source

pub fn set_error<T>(self, v: T) -> Self
where T: Into<Status>,

Sets the value of error.

§Example
use rpc::model::Status;
let x = Document::new().set_error(Status::default()/* use setters */);
Source

pub fn set_or_clear_error<T>(self, v: Option<T>) -> Self
where T: Into<Status>,

Sets or clears the value of error.

§Example
use rpc::model::Status;
let x = Document::new().set_or_clear_error(Some(Status::default()/* use setters */));
let x = Document::new().set_or_clear_error(None::<Status>);
Source

pub fn set_revisions<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<Revision>,

Sets the value of revisions.

§Example
use google_cloud_documentai_v1::model::document::Revision;
let x = Document::new()
    .set_revisions([
        Revision::default()/* use setters */,
        Revision::default()/* use (different) setters */,
    ]);
Source

pub fn set_document_layout<T>(self, v: T) -> Self
where T: Into<DocumentLayout>,

Sets the value of document_layout.

§Example
use google_cloud_documentai_v1::model::document::DocumentLayout;
let x = Document::new().set_document_layout(DocumentLayout::default()/* use setters */);
Source

pub fn set_or_clear_document_layout<T>(self, v: Option<T>) -> Self
where T: Into<DocumentLayout>,

Sets or clears the value of document_layout.

§Example
use google_cloud_documentai_v1::model::document::DocumentLayout;
let x = Document::new().set_or_clear_document_layout(Some(DocumentLayout::default()/* use setters */));
let x = Document::new().set_or_clear_document_layout(None::<DocumentLayout>);
Source

pub fn set_chunked_document<T>(self, v: T) -> Self

Sets the value of chunked_document.

§Example
use google_cloud_documentai_v1::model::document::ChunkedDocument;
let x = Document::new().set_chunked_document(ChunkedDocument::default()/* use setters */);
Source

pub fn set_or_clear_chunked_document<T>(self, v: Option<T>) -> Self

Sets or clears the value of chunked_document.

§Example
use google_cloud_documentai_v1::model::document::ChunkedDocument;
let x = Document::new().set_or_clear_chunked_document(Some(ChunkedDocument::default()/* use setters */));
let x = Document::new().set_or_clear_chunked_document(None::<ChunkedDocument>);
Source

pub fn set_entity_validation_output<T>(self, v: T) -> Self

Sets the value of entity_validation_output.

§Example
use google_cloud_documentai_v1::model::document::EntityValidationOutput;
let x = Document::new().set_entity_validation_output(EntityValidationOutput::default()/* use setters */);
Source

pub fn set_or_clear_entity_validation_output<T>(self, v: Option<T>) -> Self

Sets or clears the value of entity_validation_output.

§Example
use google_cloud_documentai_v1::model::document::EntityValidationOutput;
let x = Document::new().set_or_clear_entity_validation_output(Some(EntityValidationOutput::default()/* use setters */));
let x = Document::new().set_or_clear_entity_validation_output(None::<EntityValidationOutput>);
Source

pub fn set_entities_revisions<T, V>(self, v: T) -> Self
where T: IntoIterator<Item = V>, V: Into<EntitiesRevision>,

Sets the value of entities_revisions.

§Example
use google_cloud_documentai_v1::model::document::EntitiesRevision;
let x = Document::new()
    .set_entities_revisions([
        EntitiesRevision::default()/* use setters */,
        EntitiesRevision::default()/* use (different) setters */,
    ]);
Source

pub fn set_entities_revision_id<T: Into<String>>(self, v: T) -> Self

Sets the value of entities_revision_id.

§Example
let x = Document::new().set_entities_revision_id("example");
Source

pub fn set_source<T: Into<Option<Source>>>(self, v: T) -> Self

Sets the value of source.

Note that all the setters affecting source are mutually exclusive.

§Example
use google_cloud_documentai_v1::model::document::Source;
let x = Document::new().set_source(Some(Source::Uri("example".to_string())));
Source

pub fn uri(&self) -> Option<&String>

The value of source if it holds a Uri, None if the field is not set or holds a different branch.

Source

pub fn set_uri<T: Into<String>>(self, v: T) -> Self

Sets the value of source to hold a Uri.

Note that all the setters affecting source are mutually exclusive.

§Example
let x = Document::new().set_uri("example");
assert!(x.uri().is_some());
assert!(x.content().is_none());
Source

pub fn content(&self) -> Option<&Bytes>

The value of source if it holds a Content, None if the field is not set or holds a different branch.

Source

pub fn set_content<T: Into<Bytes>>(self, v: T) -> Self

Sets the value of source to hold a Content.

Note that all the setters affecting source are mutually exclusive.

§Example
let x = Document::new().set_content(bytes::Bytes::from_static(b"example"));
assert!(x.content().is_some());
assert!(x.uri().is_none());

Trait Implementations§

Source§

impl Clone for Document

Source§

fn clone(&self) -> Document

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for Document

Source§

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

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

impl Default for Document

Source§

fn default() -> Document

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

impl Message for Document

Source§

fn typename() -> &'static str

The typename of this message.
Source§

impl PartialEq for Document

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl StructuralPartialEq for Document

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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,