pub struct Name(/* private fields */);Expand description
A PDF name, holding its decoded bytes without the leading /.
Names are almost always ASCII identifiers, but the syntax permits any byte
through #xx escapes, so the storage is bytes rather than a String.
Specification-defined keys are 'static and cost nothing to name; parsed
ones own their bytes.
use pdfrum_object::{Name, names};
let n = Name::new(b"Length".to_vec());
assert_eq!(n.as_str(), Some("Length"));
assert_eq!(&n, names::LENGTH);
// `#xx` escapes are resolved on the way in, so spellings unify.
assert_eq!(Name::decode(b"A#42"), Name::new(b"AB".to_vec()));Implementations§
Source§impl Name
impl Name
Sourcepub const fn from_static(bytes: &'static [u8]) -> Self
pub const fn from_static(bytes: &'static [u8]) -> Self
A name from a 'static spelling, without copying. bytes must
already be decoded, which every specification-defined key is.
Sourcepub fn decode(raw: &[u8]) -> Self
pub fn decode(raw: &[u8]) -> Self
A name from the raw token following / in a file, resolving #xx
escapes — see name_decode.
Trait Implementations§
impl Eq for Name
Source§impl Ord for Name
impl Ord for Name
1.21.0 (const: unstable) · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the maximum of two values. Read more
1.21.0 (const: unstable) · Source§fn min(self, other: Self) -> Selfwhere
Self: Sized,
fn min(self, other: Self) -> Selfwhere
Self: Sized,
Compares and returns the minimum of two values. Read more
Source§impl PartialOrd for Name
impl PartialOrd for Name
impl StructuralPartialEq for Name
Auto Trait Implementations§
impl Freeze for Name
impl RefUnwindSafe for Name
impl Send for Name
impl Sync for Name
impl Unpin for Name
impl UnsafeUnpin for Name
impl UnwindSafe for Name
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more