[−][src]Struct der_parser::ber::BerObject
Representation of a BER-encoded (X.690) object
A BER object is composed of a header describing the object class, type and length, and the content.
Note that the content may sometimes not match the header tag (for ex when parsing IMPLICIT tagged values).
Fields
header: BerObjectHeader<'a>
content: BerObjectContent<'a>
Implementations
impl<'a> BerObject<'a>
[src]
pub fn from_header_and_content<'o>(
header: BerObjectHeader<'o>,
content: BerObjectContent<'o>
) -> BerObject<'o>
[src]
header: BerObjectHeader<'o>,
content: BerObjectContent<'o>
) -> BerObject<'o>
Build a BerObject from a header and content.
Note: values are not checked, so the tag can be different from the real content, or flags can be invalid.
pub fn from_obj(c: BerObjectContent<'_>) -> BerObject<'_>
[src]
Build a BerObject from its content, using default flags (no class, correct tag, and structured flag set only for Set and Sequence)
pub fn from_int_slice(i: &'a [u8]) -> BerObject<'a>
[src]
Build a DER integer object from a slice containing an encoded integer
pub fn set_raw_tag(self, raw_tag: Option<&'a [u8]>) -> BerObject<'_>
[src]
Set a tag for the BER object
pub fn from_seq(l: Vec<BerObject<'_>>) -> BerObject<'_>
[src]
Build a DER sequence object from a vector of DER objects
pub fn from_set(l: Vec<BerObject<'_>>) -> BerObject<'_>
[src]
Build a DER set object from a vector of DER objects
pub fn to_header(&self) -> BerObjectHeader<'_>
[src]
please use obj.header
or obj.header.clone()
instead
Build a BER header from this object content
pub fn as_u64(&self) -> Result<u64, BerError>
[src]
Attempt to read integer value from DER object. This can fail if the object is not an integer, or if it is too large.
let der_int = BerObject::from_int_slice(b"\x01\x00\x01"); assert_eq!( der_int.as_u64(), Ok(0x10001) );
pub fn as_u32(&self) -> Result<u32, BerError>
[src]
Attempt to read integer value from DER object. This can fail if the object is not an integer, or if it is too large.
let der_int = BerObject::from_obj(BerObjectContent::Integer(b"\x01\x00\x01")); assert_eq!( der_int.as_u32(), Ok(0x10001) );
pub fn as_bool(&self) -> Result<bool, BerError>
[src]
Attempt to read integer value from DER object. This can fail if the object is not a boolean.
pub fn as_oid(&self) -> Result<&Oid<'a>, BerError>
[src]
Attempt to read an OID value from DER object. This can fail if the object is not an OID.
pub fn as_oid_val(&self) -> Result<Oid<'a>, BerError>
[src]
Attempt to read an OID value from DER object. This can fail if the object is not an OID.
pub fn as_optional(&'a self) -> Result<Option<&BerObject<'a>>, BerError>
[src]
Attempt to get a reference on the content from an optional object. This can fail if the object is not optional.
pub fn as_tagged(
&'a self
) -> Result<(BerClass, BerTag, &BerObject<'a>), BerError>
[src]
&'a self
) -> Result<(BerClass, BerTag, &BerObject<'a>), BerError>
Attempt to get a reference on the content from a tagged object. This can fail if the object is not tagged.
pub fn as_bitstring_ref(&self) -> Result<&BitStringObject<'_>, BerError>
[src]
Attempt to read a reference to a BitString value from DER object. This can fail if the object is not an BitString.
Note that this function returns a reference to the BitString. To get an owned value,
use as_bitstring
pub fn as_bitstring(&'a self) -> Result<BitStringObject<'a>, BerError>
[src]
Attempt to read a BitString value from DER object. This can fail if the object is not an BitString.
pub fn as_sequence(&self) -> Result<&Vec<BerObject<'a>>, BerError>
[src]
Attempt to extract the list of objects from a DER sequence. This can fail if the object is not a sequence.
pub fn as_set(&self) -> Result<&Vec<BerObject<'a>>, BerError>
[src]
Attempt to extract the list of objects from a DER set. This can fail if the object is not a set.
pub fn as_slice(&self) -> Result<&'a [u8], BerError>
[src]
Attempt to get the content from a DER object, as a slice. This can fail if the object does not contain a type directly equivalent to a slice (e.g a sequence). This function mostly concerns string types, integers, or unknown DER objects.
pub fn as_str(&self) -> Result<&'a str, BerError>
[src]
Attempt to get the content from a DER object, as a str. This can fail if the object does not contain a string type.
Only NumericString, VisibleString, UTCTime, GeneralizedTime,
PrintableString, UTF8String and IA5String are considered here. Other
string types can be read using as_slice
.
pub fn is_universal(&self) -> bool
[src]
Test if object class is Universal
pub fn is_application(&self) -> bool
[src]
Test if object class is Application
pub fn is_contextspecific(&self) -> bool
[src]
Test if object class is Context-specific
pub fn is_private(&self) -> bool
[src]
Test if object class is Private
pub fn is_primitive(&self) -> bool
[src]
Test if object is primitive
pub fn is_constructed(&self) -> bool
[src]
Test if object is constructed
impl<'a> BerObject<'a>
[src]
pub fn as_bigint(&self) -> Option<BigInt>
[src]
bigint
only.pub fn as_biguint(&self) -> Option<BigUint>
[src]
bigint
only.impl<'a> BerObject<'a>
[src]
pub fn ref_iter(&'a self) -> BerObjectRefIterator<'a>ⓘNotable traits for BerObjectRefIterator<'a>
impl<'a> Iterator for BerObjectRefIterator<'a> type Item = &'a BerObject<'a>;
[src]
Notable traits for BerObjectRefIterator<'a>
impl<'a> Iterator for BerObjectRefIterator<'a> type Item = &'a BerObject<'a>;
impl<'a> BerObject<'a>
[src]
impl<'a> BerObject<'a>
[src]
pub fn to_vec(&self) -> Result<Vec<u8>, GenError>
[src]
serialize
only.Attempt to encode object as BER
Note that the encoding will not check that the values of the BerObject
fields are correct.
The length is automatically calculated, and the field is ignored.
Tagged
objects will be encoded as EXPLICIT.
This function is only available if the serialize
feature is enabled.
Trait Implementations
impl<'a> Clone for BerObject<'a>
[src]
impl<'a> Debug for BerObject<'a>
[src]
impl<'a> From<BerObjectContent<'a>> for BerObject<'a>
[src]
Build a DER object from a BerObjectContent.
fn from(obj: BerObjectContent<'a>) -> BerObject<'a>
[src]
impl<'a> From<Oid<'a>> for BerObject<'a>
[src]
Build a DER object from an OID.
impl<'a> Index<usize> for BerObject<'a>
[src]
type Output = BerObject<'a>
The returned type after indexing.
fn index(&self, idx: usize) -> &BerObject<'a>
[src]
impl<'a> IntoIterator for BerObject<'a>
[src]
type Item = BerObject<'a>
The type of the elements being iterated over.
type IntoIter = BerObjectIntoIterator<'a>
Which kind of iterator are we turning this into?
fn into_iter(self) -> Self::IntoIter
[src]
impl<'a> PartialEq<BerObject<'a>> for BerObject<'a>
[src]
impl<'a> StructuralPartialEq for BerObject<'a>
[src]
Auto Trait Implementations
impl<'a> RefUnwindSafe for BerObject<'a>
impl<'a> Send for BerObject<'a>
impl<'a> Sync for BerObject<'a>
impl<'a> Unpin for BerObject<'a>
impl<'a> UnwindSafe for BerObject<'a>
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
pub fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> Conv for T
impl<T> Conv for T
impl<T> FmtForward for T
fn fmt_binary(self) -> FmtBinary<Self> where
Self: Binary,
Self: Binary,
fn fmt_display(self) -> FmtDisplay<Self> where
Self: Display,
Self: Display,
fn fmt_lower_exp(self) -> FmtLowerExp<Self> where
Self: LowerExp,
Self: LowerExp,
fn fmt_lower_hex(self) -> FmtLowerHex<Self> where
Self: LowerHex,
Self: LowerHex,
fn fmt_octal(self) -> FmtOctal<Self> where
Self: Octal,
Self: Octal,
fn fmt_pointer(self) -> FmtPointer<Self> where
Self: Pointer,
Self: Pointer,
fn fmt_upper_exp(self) -> FmtUpperExp<Self> where
Self: UpperExp,
Self: UpperExp,
fn fmt_upper_hex(self) -> FmtUpperHex<Self> where
Self: UpperHex,
Self: UpperHex,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<I> IntoIterator for I where
I: Iterator,
[src]
I: Iterator,
type Item = <I as Iterator>::Item
The type of the elements being iterated over.
type IntoIter = I
Which kind of iterator are we turning this into?
pub fn into_iter(self) -> I
[src]
impl<T> Pipe for T where
T: ?Sized,
T: ?Sized,
fn pipe<R>(self, func: impl FnOnce(Self) -> R) -> R
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
fn pipe_ref_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
R: 'a,
fn pipe_borrow<'a, B, R>(&'a self, func: impl FnOnce(&'a B) -> R) -> R where
B: 'a + ?Sized,
R: 'a,
Self: Borrow<B>,
B: 'a + ?Sized,
R: 'a,
Self: Borrow<B>,
fn pipe_borrow_mut<'a, B, R>(
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
B: 'a + ?Sized,
R: 'a,
Self: BorrowMut<B>,
&'a mut self,
func: impl FnOnce(&'a mut B) -> R
) -> R where
B: 'a + ?Sized,
R: 'a,
Self: BorrowMut<B>,
fn pipe_as_ref<'a, U, R>(&'a self, func: impl FnOnce(&'a U) -> R) -> R where
R: 'a,
Self: AsRef<U>,
U: 'a + ?Sized,
R: 'a,
Self: AsRef<U>,
U: 'a + ?Sized,
fn pipe_as_mut<'a, U, R>(&'a mut self, func: impl FnOnce(&'a mut U) -> R) -> R where
R: 'a,
Self: AsMut<U>,
U: 'a + ?Sized,
R: 'a,
Self: AsMut<U>,
U: 'a + ?Sized,
fn pipe_deref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: Deref<Target = T>,
T: 'a + ?Sized,
R: 'a,
Self: Deref<Target = T>,
T: 'a + ?Sized,
fn pipe_deref_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: DerefMut<Target = T> + Deref,
T: 'a + ?Sized,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: DerefMut<Target = T> + Deref,
T: 'a + ?Sized,
impl<T> Pipe for T
impl<T> PipeAsRef for T
fn pipe_as_ref<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: AsRef<T>,
T: 'a,
R: 'a,
Self: AsRef<T>,
T: 'a,
fn pipe_as_mut<'a, T, R>(&'a mut self, func: impl FnOnce(&'a mut T) -> R) -> R where
R: 'a,
Self: AsMut<T>,
T: 'a,
R: 'a,
Self: AsMut<T>,
T: 'a,
impl<T> PipeBorrow for T
fn pipe_borrow<'a, T, R>(&'a self, func: impl FnOnce(&'a T) -> R) -> R where
R: 'a,
Self: Borrow<T>,
T: 'a,
R: 'a,
Self: Borrow<T>,
T: 'a,
fn pipe_borrow_mut<'a, T, R>(
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
&'a mut self,
func: impl FnOnce(&'a mut T) -> R
) -> R where
R: 'a,
Self: BorrowMut<T>,
T: 'a,
impl<T> PipeDeref for T
fn pipe_deref<'a, R>(&'a self, func: impl FnOnce(&'a Self::Target) -> R) -> R where
R: 'a,
Self: Deref,
R: 'a,
Self: Deref,
fn pipe_deref_mut<'a, R>(
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
&'a mut self,
func: impl FnOnce(&'a mut Self::Target) -> R
) -> R where
R: 'a,
Self: DerefMut,
impl<T> PipeRef for T
fn pipe_ref<'a, R>(&'a self, func: impl FnOnce(&'a Self) -> R) -> R where
R: 'a,
R: 'a,
fn pipe_mut<'a, R>(&'a mut self, func: impl FnOnce(&'a mut Self) -> R) -> R where
R: 'a,
R: 'a,
impl<T> Tap for T
fn tap(self, func: impl FnOnce(&Self)) -> Self
fn tap_mut(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_borrow<B>(self, func: impl FnOnce(&B)) -> Self where
B: ?Sized,
Self: Borrow<B>,
B: ?Sized,
Self: Borrow<B>,
fn tap_borrow_mut<B>(self, func: impl FnOnce(&mut B)) -> Self where
B: ?Sized,
Self: BorrowMut<B>,
B: ?Sized,
Self: BorrowMut<B>,
fn tap_ref<R>(self, func: impl FnOnce(&R)) -> Self where
R: ?Sized,
Self: AsRef<R>,
R: ?Sized,
Self: AsRef<R>,
fn tap_ref_mut<R>(self, func: impl FnOnce(&mut R)) -> Self where
R: ?Sized,
Self: AsMut<R>,
R: ?Sized,
Self: AsMut<R>,
fn tap_deref<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref_mut<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
fn tap_dbg(self, func: impl FnOnce(&Self)) -> Self
fn tap_mut_dbg(self, func: impl FnOnce(&mut Self)) -> Self
fn tap_borrow_dbg<B>(self, func: impl FnOnce(&B)) -> Self where
B: ?Sized,
Self: Borrow<B>,
B: ?Sized,
Self: Borrow<B>,
fn tap_borrow_mut_dbg<B>(self, func: impl FnOnce(&mut B)) -> Self where
B: ?Sized,
Self: BorrowMut<B>,
B: ?Sized,
Self: BorrowMut<B>,
fn tap_ref_dbg<R>(self, func: impl FnOnce(&R)) -> Self where
R: ?Sized,
Self: AsRef<R>,
R: ?Sized,
Self: AsRef<R>,
fn tap_ref_mut_dbg<R>(self, func: impl FnOnce(&mut R)) -> Self where
R: ?Sized,
Self: AsMut<R>,
R: ?Sized,
Self: AsMut<R>,
fn tap_deref_dbg<T>(self, func: impl FnOnce(&T)) -> Self where
Self: Deref<Target = T>,
T: ?Sized,
Self: Deref<Target = T>,
T: ?Sized,
fn tap_deref_mut_dbg<T>(self, func: impl FnOnce(&mut T)) -> Self where
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
Self: DerefMut<Target = T> + Deref,
T: ?Sized,
impl<T> Tap for T
fn tap<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
fn tap_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self) -> R,
F: FnOnce(&Self) -> R,
fn tap_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
fn tap_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self) -> R,
F: FnOnce(&mut Self) -> R,
impl<T, U> TapAsRef<U> for T where
U: ?Sized,
U: ?Sized,
fn tap_ref<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: AsRef<T>,
F: FnOnce(&T) -> R,
Self: AsRef<T>,
fn tap_ref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
fn tap_ref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
F: FnOnce(&mut T) -> R,
Self: AsMut<T>,
impl<T, U> TapBorrow<U> for T where
U: ?Sized,
U: ?Sized,
fn tap_borrow<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&T) -> R,
Self: Borrow<T>,
F: FnOnce(&T) -> R,
Self: Borrow<T>,
fn tap_borrow_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
fn tap_borrow_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
F: FnOnce(&mut T) -> R,
Self: BorrowMut<T>,
impl<T> TapDeref for T
fn tap_deref<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&Self::Target) -> R,
Self: Deref,
F: FnOnce(&Self::Target) -> R,
Self: Deref,
fn tap_deref_mut<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
fn tap_deref_mut_dbg<F, R>(self, func: F) -> Self where
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
F: FnOnce(&mut Self::Target) -> R,
Self: DerefMut,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
pub fn to_owned(&self) -> T
[src]
pub fn clone_into(&self, target: &mut T)
[src]
impl<T> TryConv for T
impl<T> TryConv for T
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,