Struct ModalEncoder
pub struct ModalEncoder<'a, 'e> { /* private fields */ }Expand description
This wraps a BinEncoder and applies different name encoding options.
Original name encoding options will be restored when this is dropped.
Methods from Deref<Target = BinEncoder<'a>>§
pub fn set_max_size(&mut self, max: u16)
pub fn set_max_size(&mut self, max: u16)
Sets the maximum size of the buffer
DNS message lens must be smaller than u16::max_value due to hard limits in the protocol
this method will move to the constructor in a future release
pub fn set_offset(&mut self, offset: usize)
pub fn set_offset(&mut self, offset: usize)
sets the current offset to the new offset
pub fn set_canonical_form(&mut self, canonical_form: bool)
pub fn set_canonical_form(&mut self, canonical_form: bool)
If set to true, then records will be written into the buffer in DNSSEC canonical form
pub fn is_canonical_form(&self) -> bool
pub fn is_canonical_form(&self) -> bool
Returns true if the encoder is writing in DNSSEC canonical form
pub fn set_name_encoding(&mut self, name_encoding: NameEncoding)
pub fn set_name_encoding(&mut self, name_encoding: NameEncoding)
Select how names are encoded
pub fn name_encoding(&self) -> NameEncoding
pub fn name_encoding(&self) -> NameEncoding
Returns the current name encoding mode
pub fn with_name_encoding<'e>(
&'e mut self,
name_encoding: NameEncoding,
) -> ModalEncoder<'a, 'e>
pub fn with_name_encoding<'e>( &'e mut self, name_encoding: NameEncoding, ) -> ModalEncoder<'a, 'e>
Returns a guard type that uses a different name encoding mode.
pub fn with_rdata_behavior<'e>(
&'e mut self,
rdata_encoding: RDataEncoding,
) -> ModalEncoder<'a, 'e>
pub fn with_rdata_behavior<'e>( &'e mut self, rdata_encoding: RDataEncoding, ) -> ModalEncoder<'a, 'e>
Returns a guard type that uses a different name encoding mode, for RDATA.
If the encoder is using canonical form, name compression will not be used. Otherwise, name compression will be used for standard record types.
If the encoder is using canonical form, the case of names will depend on the record type. Otherwise, the case will be unchanged.
pub fn trim(&mut self)
pub fn trim(&mut self)
trims to the current offset
pub fn store_label_pointer(&mut self, start: usize, end: usize)
pub fn store_label_pointer(&mut self, start: usize, end: usize)
Stores a label pointer to an already written label
The location is the current position in the buffer implicitly, it is expected that the name will be written to the stream after the current index.
pub fn get_label_pointer(&self, start: usize, end: usize) -> Option<u16>
pub fn get_label_pointer(&self, start: usize, end: usize) -> Option<u16>
Looks up the index of an already written label
pub fn emit(&mut self, b: u8) -> Result<(), ProtoError>
pub fn emit(&mut self, b: u8) -> Result<(), ProtoError>
Emit one byte into the buffer
pub fn emit_character_data<S>(&mut self, char_data: S) -> Result<(), ProtoError>
pub fn emit_character_data<S>(&mut self, char_data: S) -> Result<(), ProtoError>
matches description from above.
use hickory_proto::serialize::binary::BinEncoder;
let mut bytes: Vec<u8> = Vec::new();
{
let mut encoder: BinEncoder = BinEncoder::new(&mut bytes);
encoder.emit_character_data("abc");
}
assert_eq!(bytes, vec![3,b'a',b'b',b'c']);pub fn emit_character_data_unrestricted<S>(
&mut self,
data: S,
) -> Result<(), ProtoError>
pub fn emit_character_data_unrestricted<S>( &mut self, data: S, ) -> Result<(), ProtoError>
Emit character data of unrestricted length
Although character strings are typically restricted to being no longer than 255 characters, some modern standards allow longer strings to be encoded.
pub fn emit_u8(&mut self, data: u8) -> Result<(), ProtoError>
pub fn emit_u8(&mut self, data: u8) -> Result<(), ProtoError>
Emit one byte into the buffer
pub fn emit_u16(&mut self, data: u16) -> Result<(), ProtoError>
pub fn emit_u16(&mut self, data: u16) -> Result<(), ProtoError>
Writes a u16 in network byte order to the buffer
pub fn emit_i32(&mut self, data: i32) -> Result<(), ProtoError>
pub fn emit_i32(&mut self, data: i32) -> Result<(), ProtoError>
Writes an i32 in network byte order to the buffer
pub fn emit_u32(&mut self, data: u32) -> Result<(), ProtoError>
pub fn emit_u32(&mut self, data: u32) -> Result<(), ProtoError>
Writes an u32 in network byte order to the buffer
pub fn emit_vec(&mut self, data: &[u8]) -> Result<(), ProtoError>
pub fn emit_vec(&mut self, data: &[u8]) -> Result<(), ProtoError>
Writes the byte slice to the stream
pub fn emit_all<'e, I, E>(&mut self, iter: I) -> Result<usize, ProtoError>
pub fn emit_all<'e, I, E>(&mut self, iter: I) -> Result<usize, ProtoError>
Emits all the elements of an Iterator to the encoder
pub fn emit_all_refs<'r, 'e, I, E>(
&mut self,
iter: I,
) -> Result<usize, ProtoError>
pub fn emit_all_refs<'r, 'e, I, E>( &mut self, iter: I, ) -> Result<usize, ProtoError>
Emits all the elements of an Iterator to the encoder
pub fn emit_iter<'e, I, E>(&mut self, iter: &mut I) -> Result<usize, ProtoError>
pub fn emit_iter<'e, I, E>(&mut self, iter: &mut I) -> Result<usize, ProtoError>
emits all items in the iterator, return the number emitted
pub fn place<T>(&mut self) -> Result<Place<T>, ProtoError>where
T: EncodedSize,
pub fn place<T>(&mut self) -> Result<Place<T>, ProtoError>where
T: EncodedSize,
capture a location to write back to
pub fn len_since_place<T>(&self, place: &Place<T>) -> usizewhere
T: EncodedSize,
pub fn len_since_place<T>(&self, place: &Place<T>) -> usizewhere
T: EncodedSize,
calculates the length of data written since the place was creating
pub fn emit_at<T>(&mut self, place: Place<T>, data: T) -> Result<(), ProtoError>where
T: EncodedSize,
pub fn emit_at<T>(&mut self, place: Place<T>, data: T) -> Result<(), ProtoError>where
T: EncodedSize,
write back to a previously captured location
Trait Implementations§
§impl<'a> Deref for ModalEncoder<'a, '_>
impl<'a> Deref for ModalEncoder<'a, '_>
§type Target = BinEncoder<'a>
type Target = BinEncoder<'a>
§fn deref(&self) -> &<ModalEncoder<'a, '_> as Deref>::Target
fn deref(&self) -> &<ModalEncoder<'a, '_> as Deref>::Target
§impl DerefMut for ModalEncoder<'_, '_>
impl DerefMut for ModalEncoder<'_, '_>
§fn deref_mut(&mut self) -> &mut <ModalEncoder<'_, '_> as Deref>::Target
fn deref_mut(&mut self) -> &mut <ModalEncoder<'_, '_> as Deref>::Target
Auto Trait Implementations§
impl<'a, 'e> Freeze for ModalEncoder<'a, 'e>
impl<'a, 'e> RefUnwindSafe for ModalEncoder<'a, 'e>
impl<'a, 'e> Send for ModalEncoder<'a, 'e>
impl<'a, 'e> Sync for ModalEncoder<'a, 'e>
impl<'a, 'e> Unpin for ModalEncoder<'a, 'e>
impl<'a, 'e> UnsafeUnpin for ModalEncoder<'a, 'e>
impl<'a, 'e> !UnwindSafe for ModalEncoder<'a, 'e>
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
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
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more