Skip to main content

Document

Struct Document 

Source
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

Source

pub fn id(&self) -> DocumentId

Get the unique identifier of the document.

Source

pub fn archive_serial_number(&self) -> Option<ArchiveSerialNumber>

Get the archive serial number of the document.

Source

pub fn added(&self) -> &DateTime<Utc>

Get the timestamp when the document was added.

Source

pub fn created(&self) -> Option<&NaiveDate>

Get the created timestamp of the document.

Source

pub fn modified(&self) -> &DateTime<Utc>

Get the modified timestamp of the document.

Source

pub fn title(&self) -> &str

Get the title of the document.

Source

pub fn original_file_name(&self) -> &str

Get the original file name of the document.

Source

pub fn correspondent(&self) -> Option<CorrespondentId>

Get the correspondent id of the document.

Source

pub fn owner(&self) -> Option<UserId>

Get the owner id of the document.

Source

pub fn document_type(&self) -> Option<DocumentTypeId>

Get the document type id of the document.

Source

pub fn page_count(&self) -> u32

Get the number of pages in the document.

Source

pub fn tags(&self) -> &[TagId]

Get all tag-ids for the document.

Source

pub fn custom_fields(&self) -> &[DocumentCustomField]

Get all custom fields for the document.

Source

pub fn content(&self) -> Content<'_>

Get the content of the document.

Source

pub fn storage_path(&self) -> Option<StoragePathId>

Get the storage path of the document.

Source

pub fn notes(&self) -> &[Note]

Get the notes for the document.

Source

pub fn permissions(&self) -> &ItemPermissions

Get the permissions for the document.

Source

pub fn add_tag(&mut self, tag_id: TagId)

Add a tag to the document.

Source

pub fn remove_tag(&mut self, tag_id: TagId)

Remove a tag from the document.

Source

pub fn set_title(&mut self, title: &str)

Set the title of the document.

Source

pub fn set_content(&mut self, content: &str)

Set the content of the document.

Source

pub fn set_custom_field(&mut self, field: CustomFieldId, value: &str)

Set a custom field for the document.

Source

pub fn remove_custom_field(&mut self, field: CustomFieldId)

Remove a custom field from the document.

Source

pub fn set_created(&mut self, created: NaiveDate)

Set the created date of the document.

Source

pub fn set_owner(&mut self, owner: UserId)

Set the owner of the document.

Source

pub fn set_correspondent(&mut self, correspondent: CorrespondentId)

Set the correspondent of the document.

Source

pub fn set_document_type(&mut self, document_type: DocumentTypeId)

Set the document type of the document.

Source

pub fn set_storage_path(&mut self, storage_path: StoragePathId)

Set the storage path of the document.

Source

pub fn is_dirty(&self) -> bool

Returns true if the document has unsaved changes.

Source

pub fn is_deleted(&self) -> bool

Returns true if the document was deleted.

Source

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.

Source

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.

Source

pub async fn delete(&mut self) -> Result<(), Error>

Source

pub async fn get_full_content(&mut self) -> Result<(), Error>

Get the full content of the document, replacing any truncated content.

Source

pub async fn download_to_buffer(&self) -> Result<Vec<u8>, Error>

Download the document to a buffer.

Source

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.

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

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