Skip to content

Commit a705372

Browse files
committed
add: noting where things are required for builders
1 parent 92d2afb commit a705372

File tree

6 files changed

+45
-7
lines changed

6 files changed

+45
-7
lines changed

icann-rdap-common/src/response/autnum.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ impl Autnum {
9090
/// use icann_rdap_common::prelude::*;
9191
///
9292
/// let autnum = Autnum::builder()
93-
/// .autnum_range(700..710)
93+
/// .autnum_range(700..710) //required for this builder
9494
/// .handle("AS700-1")
9595
/// .status("active")
9696
/// .build();

icann-rdap-common/src/response/domain.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -480,7 +480,7 @@ impl Domain {
480480
/// use icann_rdap_common::prelude::*;
481481
///
482482
/// let domain = Domain::builder()
483-
/// .ldh_name("foo.example.com")
483+
/// .ldh_name("foo.example.com") //required for this builder.
484484
/// .handle("foo_example_com-1")
485485
/// .status("active")
486486
/// .build();
@@ -536,7 +536,7 @@ impl Domain {
536536
/// use icann_rdap_common::prelude::*;
537537
///
538538
/// let domain = Domain::idn()
539-
/// .unicode_name("foo.example.com")
539+
/// .unicode_name("foo.example.com") // required for this builder
540540
/// .handle("foo_example_com-1")
541541
/// .status("active")
542542
/// .build();

icann-rdap-common/src/response/error.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,15 @@ pub struct Rfc9083Error {
5555
#[buildstructor::buildstructor]
5656
impl Rfc9083Error {
5757
/// Creates a new RFC 9083 Error for a specific HTTP error code.
58+
///
59+
/// Use this builder to create a generic error:
60+
/// ```rust
61+
/// use icann_rdap_common::prelude::*;
62+
///
63+
/// let e = Rfc9083Error::builder()
64+
/// .error_code(500) //required
65+
/// .build();
66+
/// ```
5867
#[builder(visibility = "pub")]
5968
fn new(error_code: u16, notices: Vec<Notice>, extensions: Vec<Extension>) -> Self {
6069
let notices = (!notices.is_empty()).then_some(notices);

icann-rdap-common/src/response/nameserver.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ impl Nameserver {
161161
/// use icann_rdap_common::prelude::*;
162162
///
163163
/// let ns = Nameserver::builder()
164-
/// .ldh_name("ns1.example.com")
164+
/// .ldh_name("ns1.example.com") //required for this builder
165165
/// .handle("ns1_example_com-1")
166166
/// .status("active")
167167
/// .address("10.0.0.1")

icann-rdap-common/src/response/network.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,7 @@ impl Network {
237237
/// use icann_rdap_common::prelude::*;
238238
///
239239
/// let net = Network::builder()
240-
/// .cidr("10.0.0.0/24")
240+
/// .cidr("10.0.0.0/24") //required for this builder
241241
/// .handle("NET-10-0-0-0")
242242
/// .status("active")
243243
/// .build().unwrap();

icann-rdap-common/src/response/types.rs

Lines changed: 31 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,15 @@ pub type RdapConformance = Vec<Extension>;
4646
/// println!("{}", cidr0.to_string());
4747
/// ```
4848
///
49-
/// To get the variants as a string:
49+
/// To get the enum variants as a string:
5050
///
5151
/// ```rust
5252
/// use icann_rdap_common::prelude::*;
5353
///
5454
/// let s = ExtensionId::Cidr0.to_string();
5555
/// ```
5656
///
57-
/// To get the variants as a &str:
57+
/// To get the enum variants as a &str:
5858
///
5959
/// ```rust
6060
/// use icann_rdap_common::prelude::*;
@@ -215,6 +215,23 @@ impl Link {
215215
}
216216

217217
/// Builds an RDAP link.
218+
///
219+
/// To create an RFC valid structure, use the builder
220+
/// which will not allow omision of required fields.
221+
///
222+
/// ```rust
223+
/// use icann_rdap_common::prelude::*;
224+
///
225+
/// let link = Link::builder()
226+
/// .value("https://example.com/domains?domain=foo.*") //required
227+
/// .rel("related") //required
228+
/// .href("https://example.com/domain/foo.example") //required
229+
/// .hreflang("ch")
230+
/// .title("Related Object")
231+
/// .media("print")
232+
/// .media_type("application/rdap+json")
233+
/// .build();
234+
/// ```
218235
#[builder(visibility = "pub")]
219236
fn new(
220237
value: String,
@@ -586,6 +603,18 @@ pub struct Event {
586603
#[buildstructor::buildstructor]
587604
impl Event {
588605
/// Builds an Event.
606+
///
607+
/// Use of the builder to contruct an RFC valid structure is recommended.
608+
///
609+
/// ```rust
610+
/// use icann_rdap_common::prelude::*;
611+
///
612+
/// let event = Event::builder()
613+
/// .event_action("expiration") //required
614+
/// .event_date("1990-12-31T23:59:59Z") //required
615+
/// .event_actor("FOO")
616+
/// .build();
617+
/// ```
589618
#[builder(visibility = "pub")]
590619
fn new(
591620
event_action: String,

0 commit comments

Comments
 (0)