Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ jiff = { version = "0.2.1", default-features = false }
arbitrary = { version = "1.4.1", optional = true, features = ["derive"] }
bumpalo = { version = "3.12", optional = true }
constant_time_eq = { version = "0.4.2", optional = true }
octseq = { version = "0.6.0", default-features = false }
octseq = { version = "0.6.1", default-features = false }
rand = { version = "0.10.1", optional = true }
arc-swap = { version = "1.7.0", optional = true }
bytes = { version = "1.2", optional = true, default-features = false }
Expand All @@ -57,7 +57,7 @@ proc-macro2 = { version = "1.0.69", optional = true } # Force proc-macro2 to
ring = { version = "0.17.2", optional = true }
rustversion = { version = "1", optional = true }
secrecy = { version = "0.10", optional = true }
serde = { version = "1.0.130", optional = true, features = ["derive"] }
serde = { version = "1.0.130", optional = true, default-features = false, features = ["derive"] }
siphasher = { version = "1", optional = true }
smallvec = { version = "1.3", optional = true }
tokio = { version = "1.33", optional = true, features = ["io-util", "macros", "net", "time", "sync", "rt-multi-thread" ] }
Expand All @@ -70,15 +70,15 @@ tracing-subscriber = { version = "0.3.18", optional = true, features = ["env-fil
default = ["std", "rand"]

# Support for libraries
alloc = ["jiff/alloc"]
alloc = ["jiff/alloc", "octseq/alloc", "serde?/alloc"]
bumpalo = ["dep:bumpalo", "std"]
bytes = ["dep:bytes", "octseq/bytes"]
chrono = ["dep:chrono"]
heapless = ["dep:heapless", "octseq/heapless"]
rand = ["dep:rand"]
serde = ["std", "dep:serde", "octseq/serde"]
serde = ["dep:serde", "octseq/serde"]
smallvec = ["dep:smallvec", "octseq/smallvec"]
std = ["alloc", "dep:hashbrown", "bumpalo?/std", "bytes?/std", "octseq/std", "jiff/std"]
std = ["alloc", "dep:hashbrown", "bumpalo?/std", "bytes?/std", "octseq/std", "jiff/std", "serde?/std"]
tracing = ["dep:log", "dep:tracing"]

# Cryptographic backends
Expand Down
16 changes: 8 additions & 8 deletions src/base/charstr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
use super::cmp::CanonicalOrd;
use super::scan::{BadSymbol, Scanner, Symbol, SymbolCharsError};
use super::wire::{Compose, ParseError};
#[cfg(feature = "alloc")]
use alloc::vec::Vec;
#[cfg(feature = "bytes")]
use bytes::BytesMut;
use core::{cmp, fmt, hash, mem, str};
Expand All @@ -36,8 +38,6 @@ use octseq::{
EmptyBuilder, FromBuilder, IntoBuilder, Octets, OctetsBuilder,
OctetsFrom, Parser, ShortBuf, Truncate,
};
#[cfg(feature = "std")]
use std::vec::Vec;

//------------ CharStr -------------------------------------------------------

Expand Down Expand Up @@ -661,10 +661,10 @@ where
})
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
fn visit_byte_buf<E: serde::de::Error>(
self,
value: std::vec::Vec<u8>,
value: alloc::vec::Vec<u8>,
) -> Result<Self::Value, E> {
self.0.visit_byte_buf(value).and_then(|octets| {
CharStr::from_octets(octets).map_err(E::custom)
Expand Down Expand Up @@ -757,7 +757,7 @@ impl<Builder: OctetsBuilder + AsRef<[u8]>> CharStrBuilder<Builder> {
}
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
impl CharStrBuilder<Vec<u8>> {
/// Creates a new empty characater string builder atop an octets vec.
#[must_use]
Expand Down Expand Up @@ -1211,7 +1211,7 @@ impl core::error::Error for PresentationError {}
//============ Testing =======================================================

#[cfg(test)]
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
mod test {
use super::*;
use octseq::builder::infallible;
Expand Down Expand Up @@ -1242,7 +1242,7 @@ mod test {

#[test]
fn from_str() {
use std::str::{from_utf8, FromStr};
use core::str::{from_utf8, FromStr};

type Cs = CharStr<Vec<u8>>;

Expand Down Expand Up @@ -1319,7 +1319,7 @@ mod test {

#[test]
fn ord() {
use std::cmp::Ordering::*;
use core::cmp::Ordering::*;

is_ord(b"abc", b"ABC", Equal);
is_ord(b"abc", b"a", Greater);
Expand Down
14 changes: 7 additions & 7 deletions src/base/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,13 +125,13 @@ impl Header {
/// incoming responses to their queries.
///
/// When choosing an ID for an outgoing message, make sure it is random
/// to avoid spoofing by guessing the message ID. If `std` support
/// to avoid spoofing by guessing the message ID. If `rand` support
/// is enabled, the method
#[cfg_attr(
feature = "std",
feature = "rand",
doc = "[`set_random_id`][Self::set_random_id]"
)]
#[cfg_attr(not(feature = "std"), doc = "`set_random_id`")]
#[cfg_attr(not(feature = "rand"), doc = "`set_random_id`")]
/// can be used for this purpose.
#[must_use]
pub fn id(self) -> u16 {
Expand Down Expand Up @@ -961,9 +961,9 @@ mod test {
use super::*;

#[test]
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
fn for_slice() {
use std::vec::Vec;
use alloc::vec::Vec;

let header = b"\x01\x02\x00\x00\x12\x34\x56\x78\x9a\xbc\xde\xf0";
let mut vec = Vec::from(&header[..]);
Expand Down Expand Up @@ -1119,7 +1119,7 @@ mod test {
assert!(c.inc_arcount().is_err());
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
#[test]
fn flags_display() {
let f = Flags::new();
Expand All @@ -1140,7 +1140,7 @@ mod test {
assert_eq!(format!("{}", f), "RD CD");
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
#[test]
fn flags_from_str() {
let f1 = Flags::from_str("").unwrap();
Expand Down
2 changes: 1 addition & 1 deletion src/base/iana/class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ mod test {
assert_tokens(&Class(5).compact(), &[Token::U16(5)]);
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
#[test]
fn debug() {
use super::Class;
Expand Down
18 changes: 9 additions & 9 deletions src/base/message.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1352,17 +1352,17 @@ impl core::error::Error for CopyRecordsError {}
#[cfg(test)]
mod test {
use super::*;
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
use crate::base::message_builder::MessageBuilder;
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
use crate::base::name::Name;
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
use crate::rdata::{AllRecordData, Ns};
#[cfg(feature = "std")]
use std::vec::Vec;
#[cfg(feature = "alloc")]
use alloc::vec::Vec;

// Helper for test cases
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
fn get_test_message() -> Message<Vec<u8>> {
let msg = MessageBuilder::new_vec();
let mut msg = msg.answer();
Expand All @@ -1389,7 +1389,7 @@ mod test {
}

#[test]
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
fn canonical_name() {
use crate::rdata::A;

Expand Down Expand Up @@ -1447,7 +1447,7 @@ mod test {
}

#[test]
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
fn message_iterator() {
let msg = get_test_message();
let mut iter = msg.iter();
Expand All @@ -1462,7 +1462,7 @@ mod test {
}

#[test]
#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
fn copy_records() {
let msg = get_test_message();
let target = MessageBuilder::new_vec().question();
Expand Down
32 changes: 16 additions & 16 deletions src/base/message_builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,8 @@
//! The following example builds a message with both name compression and
//! the stream length and simply puts two A records into it.
//!
#![cfg_attr(feature = "std", doc = "```")]
#![cfg_attr(not(feature = "std"), doc = "```ignore")]
#![cfg_attr(feature = "alloc", doc = "```")]
#![cfg_attr(not(feature = "alloc"), doc = "```ignore")]
//! use std::str::FromStr;
//! use domain::base::{
//! Name, MessageBuilder, Rtype, StaticCompressor, StreamTarget
Expand Down Expand Up @@ -137,6 +137,8 @@ use super::opt::{ComposeOptData, OptHeader, OptRecord};
use super::question::ComposeQuestion;
use super::record::ComposeRecord;
use super::wire::{Compose, Composer};
#[cfg(feature = "alloc")]
use alloc::vec::Vec;
#[cfg(feature = "bytes")]
use bytes::BytesMut;
use core::ops::{Deref, DerefMut};
Expand All @@ -145,16 +147,14 @@ use core::{fmt, mem};
use hashbrown::HashTable;
#[cfg(feature = "std")]
use octseq::array::Array;
#[cfg(any(feature = "std", feature = "bytes"))]
#[cfg(any(feature = "alloc", feature = "bytes"))]
use octseq::builder::infallible;
use octseq::builder::{FreezeBuilder, OctetsBuilder, ShortBuf, Truncate};
use octseq::octets::Octets;
#[cfg(feature = "std")]
use std::collections::{hash_map::RandomState, HashMap};
#[cfg(feature = "std")]
use std::hash::BuildHasher;
#[cfg(feature = "std")]
use std::vec::Vec;

//------------ MessageBuilder ------------------------------------------------

Expand Down Expand Up @@ -201,7 +201,7 @@ impl<Target: OctetsBuilder + Truncate> MessageBuilder<Target> {
}
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
impl MessageBuilder<Vec<u8>> {
/// Creates a new message builder atop a `Vec<u8>`.
#[must_use]
Expand All @@ -210,7 +210,7 @@ impl MessageBuilder<Vec<u8>> {
}
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
impl MessageBuilder<StreamTarget<Vec<u8>>> {
/// Creates a new builder for a streamable message atop a `Vec<u8>`.
#[must_use]
Expand Down Expand Up @@ -599,8 +599,8 @@ impl<Target: Composer> QuestionBuilder<Target> {
///
/// In other words, the options are:
///
#[cfg_attr(feature = "std", doc = "```")]
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "alloc", doc = "```")]
#[cfg_attr(not(feature = "alloc"), doc = "```ignore")]
/// use domain::base::{Name, MessageBuilder, Question, Rtype};
/// use domain::base::iana::Class;
///
Expand Down Expand Up @@ -851,8 +851,8 @@ impl<Target: Composer> AnswerBuilder<Target> {
///
/// In other words, you can do the following things:
///
#[cfg_attr(feature = "std", doc = "```")]
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "alloc", doc = "```")]
#[cfg_attr(not(feature = "alloc"), doc = "```ignore")]
/// use domain::base::{Name, MessageBuilder, Record, Rtype, Ttl};
/// use domain::base::iana::Class;
/// use domain::rdata::A;
Expand Down Expand Up @@ -1116,8 +1116,8 @@ impl<Target: Composer> AuthorityBuilder<Target> {
///
/// In other words, you can do the following things:
///
#[cfg_attr(feature = "std", doc = "```")]
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "alloc", doc = "```")]
#[cfg_attr(not(feature = "alloc"), doc = "```ignore")]
/// use domain::base::{Name, MessageBuilder, Record, Rtype, Ttl};
/// use domain::base::iana::Class;
/// use domain::rdata::A;
Expand Down Expand Up @@ -1374,8 +1374,8 @@ impl<Target: Composer> AdditionalBuilder<Target> {
///
/// In other words, you can do the following things:
///
#[cfg_attr(feature = "std", doc = "```")]
#[cfg_attr(not(feature = "std"), doc = "```ignore")]
#[cfg_attr(feature = "alloc", doc = "```")]
#[cfg_attr(not(feature = "alloc"), doc = "```ignore")]
/// use domain::base::{Name, MessageBuilder, Record, Rtype, Ttl};
/// use domain::base::iana::Class;
/// use domain::rdata::A;
Expand Down Expand Up @@ -1849,7 +1849,7 @@ impl<Target: Composer> StreamTarget<Target> {
}
}

#[cfg(feature = "std")]
#[cfg(feature = "alloc")]
impl StreamTarget<Vec<u8>> {
/// Creates a stream target atop an empty `Vec<u8>`.
#[must_use]
Expand Down
Loading
Loading