diff options
| author | Jake Sandler | 2018-06-09 10:36:04 -0400 | 
|---|---|---|
| committer | Jake Sandler | 2018-06-09 10:36:04 -0400 | 
| commit | 2f175f59b033ebe74f86e08becb2bc1e759bdeee (patch) | |
| tree | 60406b9e7110875e5ff86f4f566da83b0a2ed908 /src/lib.rs | |
| parent | 5b593bd686e91a2e15640a6f77aedd5d1a893e50 (diff) | |
| download | pdf_form-2f175f59b033ebe74f86e08becb2bc1e759bdeee.tar.bz2 | |
added std::error::Error Implmentations
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 20 | 
1 files changed, 13 insertions, 7 deletions
| @@ -2,6 +2,8 @@  extern crate lopdf;  #[macro_use]  extern crate bitflags; +#[macro_use] +extern crate derive_error;  use lopdf::{Document, ObjectId, Object, StringFormat};  use std::path::Path; @@ -67,29 +69,33 @@ pub enum FieldState {      Text { text: String }  } -#[derive(Debug)] +#[derive(Debug, Error)]  /// Errors that may occur while loading a PDF  pub enum LoadError { +    /// An IO Error      IoError(io::Error), +    /// A dictionary key that must be present in order to find forms was not present      DictionaryKeyNotFound, +    /// The reference `ObjectId` did not point to any values +    #[error(non_std, no_from)]      NoSuchReference(ObjectId), +    /// An element that was expected to be a reference was not a reference      NotAReference, +    /// A value that must be a certain type was not that type      UnexpectedType  }  /// Errors That may occur while setting values in a form +#[derive(Debug, Error)]  pub enum ValueError { +    /// The method used to set the state is incompatible with the type of the field      TypeMismatch, +    /// One or more selected values are not valid choices      InvalidSelection, +    /// Multiple values were selected when only one was allowed      TooManySelected  } -impl From<io::Error> for LoadError { -     fn from(error: io::Error) -> Self { -        LoadError::IoError(error) -     } -} -  trait PdfObjectDeref {      fn deref<'a>(&self, doc: &'a Document) -> Result<&'a Object, LoadError>;  } | 
