pub struct Document { /* private fields */ }Expand description
Represents a document.
Changes made through mutating methods such as
set_title,
set_content,
add_tag, and
set_custom_field
are only tracked locally at first.
They are not sent to the Paperless server until
patch is called.
Implementations§
Source§impl Document
impl Document
Sourcepub fn id(&self) -> DocumentId
pub fn id(&self) -> DocumentId
Get the unique identifier of the document.
Sourcepub fn archive_serial_number(&self) -> Option<ArchiveSerialNumber>
pub fn archive_serial_number(&self) -> Option<ArchiveSerialNumber>
Get the archive serial number of the document.
Sourcepub fn original_file_name(&self) -> &str
pub fn original_file_name(&self) -> &str
Get the original file name of the document.
Sourcepub fn correspondent(&self) -> Option<CorrespondentId>
pub fn correspondent(&self) -> Option<CorrespondentId>
Get the correspondent id of the document.
Sourcepub fn document_type(&self) -> Option<DocumentTypeId>
pub fn document_type(&self) -> Option<DocumentTypeId>
Get the document type id of the document.
Sourcepub fn page_count(&self) -> Option<u32>
pub fn page_count(&self) -> Option<u32>
Get the number of pages in the document.
Get all tag-ids for the document.
Sourcepub fn custom_fields(&self) -> &[DocumentCustomField]
pub fn custom_fields(&self) -> &[DocumentCustomField]
Get all custom fields for the document.
Sourcepub fn storage_path(&self) -> Option<StoragePathId>
pub fn storage_path(&self) -> Option<StoragePathId>
Get the storage path of the document.
Sourcepub fn permissions(&self) -> &ItemPermissions
pub fn permissions(&self) -> &ItemPermissions
Get the permissions for the document.
Sourcepub fn set_archive_serial_number(
&mut self,
archive_serial_number: Option<ArchiveSerialNumber>,
)
pub fn set_archive_serial_number( &mut self, archive_serial_number: Option<ArchiveSerialNumber>, )
Set the archive serial number of the document.
Sourcepub fn remove_tag(&mut self, tag_id: TagId)
pub fn remove_tag(&mut self, tag_id: TagId)
Remove a tag from the document.
Sourcepub fn set_content(&mut self, content: impl Into<String>)
pub fn set_content(&mut self, content: impl Into<String>)
Set the content of the document.
Sourcepub fn set_custom_field(
&mut self,
field: CustomFieldId,
value: impl Into<String>,
)
pub fn set_custom_field( &mut self, field: CustomFieldId, value: impl Into<String>, )
Set a custom field for the document.
Sourcepub fn remove_custom_field(&mut self, field: CustomFieldId)
pub fn remove_custom_field(&mut self, field: CustomFieldId)
Remove a custom field from the document.
Sourcepub fn set_created(&mut self, created: NaiveDate)
pub fn set_created(&mut self, created: NaiveDate)
Set the created date of the document.
Sourcepub fn set_correspondent(&mut self, correspondent: CorrespondentId)
pub fn set_correspondent(&mut self, correspondent: CorrespondentId)
Set the correspondent of the document.
Sourcepub fn set_document_type(&mut self, document_type: DocumentTypeId)
pub fn set_document_type(&mut self, document_type: DocumentTypeId)
Set the document type of the document.
Sourcepub fn set_storage_path(&mut self, storage_path: StoragePathId)
pub fn set_storage_path(&mut self, storage_path: StoragePathId)
Set the storage path of the document.
Sourcepub fn is_deleted(&self) -> bool
pub fn is_deleted(&self) -> bool
Returns true if the document was deleted.
Sourcepub async fn refresh(&mut self) -> Result<(), Error>
pub async fn refresh(&mut self) -> Result<(), Error>
Refresh the document from the server.
This will discard any local changes and replace them with the server’s state.
Sourcepub async fn thumbnail(&self) -> Result<Vec<u8>, Error>
pub async fn thumbnail(&self) -> Result<Vec<u8>, Error>
Get the document thumbnail.
Returns the raw thumbnail image data.
Sourcepub async fn patch(&mut self) -> Result<(), Error>
pub async fn patch(&mut self) -> Result<(), Error>
Update the document on the server.
This applies the currently tracked local changes to the remote Paperless document.
Sourcepub async fn get_full_content(&mut self) -> Result<(), Error>
pub async fn get_full_content(&mut self) -> Result<(), Error>
Get the full content of the document, replacing any truncated content.
Sourcepub async fn download_to_buffer(&self) -> Result<Vec<u8>, Error>
pub async fn download_to_buffer(&self) -> Result<Vec<u8>, Error>
Download the document to a buffer.
Sourcepub async fn download_to_file(&self, path: &Path) -> Result<(), Error>
pub async fn download_to_file(&self, path: &Path) -> Result<(), Error>
Download the document to a file, requires the tokio-fs feature.
Generates a share link for the document that expires after the specified duration.
Generates a share link for the document that expires at the specified time.