diff --git a/src/main/java/dev.toad/Client.java b/src/main/java/dev.toad/Client.java index 3a52ff2..2ac3be2 100644 --- a/src/main/java/dev.toad/Client.java +++ b/src/main/java/dev.toad/Client.java @@ -1,6 +1,10 @@ package dev.toad; +import dev.toad.msg.Code; +import dev.toad.msg.Type; import dev.toad.msg.Message; +import java.net.URISyntaxException; +import java.net.UnknownHostException; import java.util.Optional; import java.util.concurrent.CompletableFuture; @@ -12,6 +16,14 @@ public final class Client implements AutoCloseable { this.toad = toad; } + public CompletableFuture get(String uri) throws URISyntaxException, UnknownHostException { + return this.get(Type.CON, uri); + } + + public CompletableFuture get(Type ty, String uri) throws URISyntaxException, UnknownHostException { + return this.send(Message.builder().uri(uri).type(ty).code(Code.GET).build()); + } + public CompletableFuture send(Message message) { if (message.addr().isEmpty()) { throw new IllegalArgumentException( diff --git a/src/main/java/dev.toad/ffi/u16.java b/src/main/java/dev.toad/ffi/u16.java index acb2961..57b71bd 100644 --- a/src/main/java/dev.toad/ffi/u16.java +++ b/src/main/java/dev.toad/ffi/u16.java @@ -15,4 +15,16 @@ public final class u16 { public int intValue() { return this.l; } + + @Override + public boolean equals(Object other) { + return switch (other) { + case u16 o -> this.equals(o); + default -> false; + }; + } + + public boolean equals(u16 other) { + return this.intValue() == other.intValue(); + } } diff --git a/src/main/java/dev.toad/ffi/u32.java b/src/main/java/dev.toad/ffi/u32.java index 65424bf..cfd39dc 100644 --- a/src/main/java/dev.toad/ffi/u32.java +++ b/src/main/java/dev.toad/ffi/u32.java @@ -15,4 +15,16 @@ public final class u32 { public long longValue() { return this.l; } + + @Override + public boolean equals(Object other) { + return switch (other) { + case u32 o -> this.equals(o); + default -> false; + }; + } + + public boolean equals(u32 other) { + return this.longValue() == other.longValue(); + } } diff --git a/src/main/java/dev.toad/ffi/u64.java b/src/main/java/dev.toad/ffi/u64.java index a944667..816b843 100644 --- a/src/main/java/dev.toad/ffi/u64.java +++ b/src/main/java/dev.toad/ffi/u64.java @@ -23,4 +23,16 @@ public final class u64 { public BigInteger bigintValue() { return this.l; } + + @Override + public boolean equals(Object other) { + return switch (other) { + case u64 o -> this.equals(o); + default -> false; + }; + } + + public boolean equals(u64 other) { + return this.bigintValue() == other.bigintValue(); + } } diff --git a/src/main/java/dev.toad/ffi/u8.java b/src/main/java/dev.toad/ffi/u8.java index 3663e01..120cca1 100644 --- a/src/main/java/dev.toad/ffi/u8.java +++ b/src/main/java/dev.toad/ffi/u8.java @@ -13,4 +13,16 @@ public final class u8 { public short shortValue() { return this.l; } + + @Override + public boolean equals(Object other) { + return switch (other) { + case u8 o -> this.equals(o); + default -> false; + }; + } + + public boolean equals(u8 other) { + return this.shortValue() == other.shortValue(); + } } diff --git a/src/main/java/dev.toad/msg/Message.java b/src/main/java/dev.toad/msg/Message.java index 1376f92..734c487 100644 --- a/src/main/java/dev.toad/msg/Message.java +++ b/src/main/java/dev.toad/msg/Message.java @@ -1,5 +1,7 @@ package dev.toad.msg; +import dev.toad.msg.option.Accept; +import dev.toad.msg.option.ContentFormat; import dev.toad.msg.option.Path; import dev.toad.msg.option.Host; import dev.toad.msg.option.Query; @@ -8,6 +10,10 @@ import java.util.List; import java.util.Optional; public interface Message { + public static dev.toad.msg.build.MessageNeeds.Destination builder() { + return dev.toad.msg.build.Message.builder(); + } + public Optional addr(); public Id id(); @@ -20,10 +26,26 @@ public interface Message { public List