pub struct BerObject<'a> {
pub header: Header<'a>,
pub content: BerObjectContent<'a>,
}
Expand description
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).
Source§ SourceBuild 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.
SourceBuild a BerObject from its content, using default flags (no class, correct tag, and constructed flag set only for Set and Sequence)
SourceBuild a DER integer object from a slice containing an encoded integer
SourceSet a tag for the BER object
SourceBuild a DER sequence object from a vector of DER objects
SourceBuild a DER set object from a vector of DER objects
SourceAttempt to read a signed integer value from DER object.
This can fail if the object is not an integer, or if it is too large.
§Exampleslet der_int = BerObject::from_int_slice(b"\x80");
assert_eq!(
der_int.as_i64(),
Ok(-128)
);
Source
Attempt to read a signed integer value from DER object.
This can fail if the object is not an integer, or if it is too large.
§Exampleslet der_int = BerObject::from_int_slice(b"\x80");
assert_eq!(
der_int.as_i32(),
Ok(-128)
);
Source
Attempt to read integer value from DER object.
This can fail if the object is not an unsigned integer, or if it is too large.
§Exampleslet der_int = BerObject::from_int_slice(b"\x01\x00\x01");
assert_eq!(
der_int.as_u64(),
Ok(0x10001)
);
Source
Attempt to read integer value from DER object.
This can fail if the object is not an unsigned integer, or if it is too large.
§Exampleslet der_int = BerObject::from_obj(BerObjectContent::Integer(b"\x01\x00\x01"));
assert_eq!(
der_int.as_u32(),
Ok(0x10001)
);
Source
Attempt to read integer value from DER object. This can fail if the object is not a boolean.
SourceAttempt to read an OID value from DER object. This can fail if the object is not an OID.
SourceAttempt to read an OID value from DER object. This can fail if the object is not an OID.
SourceAttempt to get a reference on the content from an optional object. This can fail if the object is not optional.
SourceAttempt to get a reference on the content from a tagged object. This can fail if the object is not tagged.
SourceAttempt 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
Attempt to read a BitString value from DER object. This can fail if the object is not an BitString.
SourceConstructs a shared &BitSlice
reference over the object data, if available as slice.
Attempt to extract the list of objects from a DER sequence. This can fail if the object is not a sequence.
SourceAttempt to extract the list of objects from a DER set. This can fail if the object is not a set.
SourceAttempt 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.
SourceAttempt to get the content from a DER object, as a str. This can fail if the object does not contain a string type.
Only some string types are considered here. Other string types can be read using as_slice
.
Get the BER object header’s class.
SourceGet the BER object header’s tag.
SourceGet the BER object header’s length.
SourceTest if object class is Universal
SourceTest if object class is Application
SourceTest if object class is Context-specific
SourceTest if object class is Private
SourceTest if object is primitive
SourceTest if object is constructed
SourceReturn error if class
is not the expected class
Return error if tag
is not the expected tag
Return error if object is not constructed
SourceReturn error if object is not primitive
Source§ SourceAvailable on crate feature bigint
only.
Attempt to read an integer value from this object.
This can fail if the object is not an integer.
§Examplesuse der_parser::ber::*;
let data = &[0x02, 0x03, 0x01, 0x00, 0x01];
let (_, object) = parse_ber_integer(data).expect("parsing failed");
assert_eq!(object.as_bigint(), Ok(65537.into()))
Source
Available on crate feature bigint
only.
Attempt to read a positive integer value from this object.
This can fail if the object is not an integer, or is negative.
§Examplesuse der_parser::ber::*;
let data = &[0x02, 0x03, 0x01, 0x00, 0x01];
let (_, object) = parse_ber_integer(data).expect("parsing failed");
assert_eq!(object.as_biguint(), Ok(65537_u32.into()))
Source§ Source§ Source§ Source
Available on crate feature 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.
Build a DER object from a BerObjectContent.
Source§Converts to this type from the input type.
Source§Build a DER object from an OID.
Source§Converts to this type from the input type.
Source§ Source§ Source§The type of the elements being iterated over.
Source§Which kind of iterator are we turning this into?
Source§ Source§ Source§Tests for self
and other
values to be equal, and is used by ==
.
Tests for !=
. The default implementation is almost always sufficient, and should not be overridden without very good reason.
The type returned in the event of a conversion error.
Source§Performs the conversion.
Source§ Source§The type returned in the event of a conversion error.
Source§Performs the conversion.
Source§ Source§ Source§ Source§ Source§ Source§ Source§ Source§🔬This is a nightly-only experimental API. (clone_to_uninit
)
Performs copy-assignment from
self
to
dest
.
Read more Source§ Source§ Source§Causes self
to use its Binary
implementation when Debug
-formatted.
Causes self
to use its Display
implementation when Debug
-formatted.
Causes self
to use its LowerExp
implementation when Debug
-formatted.
Causes self
to use its LowerHex
implementation when Debug
-formatted.
Causes self
to use its Octal
implementation when Debug
-formatted.
Causes self
to use its Pointer
implementation when Debug
-formatted.
Causes self
to use its UpperExp
implementation when Debug
-formatted.
Causes self
to use its UpperHex
implementation when Debug
-formatted.
Returns the argument unchanged.
Source§ Source§Attempt to parse input bytes into a BER object
Source§ Source§Calls U::from(self)
.
That is, this conversion is whatever the implementation of From<T> for U
chooses to do.
Pipes by value. This is generally the method you want to use.
Read more Source§Borrows
self
and passes that borrow into the pipe function.
Read more Source§Mutably borrows
self
and passes that borrow into the pipe function.
Read more Source§Borrows
self
, then passes
self.borrow()
into the pipe function.
Read more Source§Mutably borrows
self
, then passes
self.borrow_mut()
into the pipe function.
Read more Source§Borrows self
, then passes self.as_ref()
into the pipe function.
Mutably borrows self
, then passes self.as_mut()
into the pipe function.
Borrows self
, then passes self.deref()
into the pipe function.
Mutably borrows self
, then passes self.deref_mut()
into the pipe function.
Immutable access to the
Borrow<B>
of a value.
Read more Source§Mutable access to the
BorrowMut<B>
of a value.
Read more Source§Immutable access to the
AsRef<R>
view of a value.
Read more Source§Mutable access to the
AsMut<R>
view of a value.
Read more Source§Immutable access to the
Deref::Target
of a value.
Read more Source§Mutable access to the
Deref::Target
of a value.
Read more Source§Calls .tap()
only in debug builds, and is erased in release builds.
Calls .tap_mut()
only in debug builds, and is erased in release builds.
Calls .tap_borrow()
only in debug builds, and is erased in release builds.
Calls .tap_borrow_mut()
only in debug builds, and is erased in release builds.
Calls .tap_ref()
only in debug builds, and is erased in release builds.
Calls .tap_ref_mut()
only in debug builds, and is erased in release builds.
Calls .tap_deref()
only in debug builds, and is erased in release builds.
Calls .tap_deref_mut()
only in debug builds, and is erased in release builds.
The resulting type after obtaining ownership.
Source§Creates owned data from borrowed data, usually by cloning.
Read more Source§Uses borrowed data to replace owned data, usually by cloning.
Read more Source§ Source§ Source§The type returned in the event of a conversion error.
Source§Performs the conversion.
Source§ Source§The type returned in the event of a conversion error.
Source§Performs the conversion.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4