Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc: Add D client #112

Merged
merged 1 commit into from
Jan 6, 2025
Merged
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
58 changes: 58 additions & 0 deletions astro/content/docs/clients/d.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
---
title: D
description: How to install and use Ada in a D project
---

Ada has a D client available on [Github][source-code] and
also on [dub.pm][dub-registry].

## Installation

Add the following as a dependency to your project (`dub.json` or `dub.sdl`):

```bash
# dub add ada-d from dub-registry
$ dub add ada-d
```

Modules hierarchy:

```bash
.
└── source
├── c
│   ├── ada.d # low-level C bindings - @nogc, nothrow, @safe and betterC compatible
│   └── wrapper.d # D (mangled) RAII - nothrow, @safe and betterC compatible
└── package.d # by default set public wrapper.d in 'import ada_url'
# (for low-level C bindings use 'import c.ada')
```

## Usage

Here is an example illustrating a common usage:

```d
import ada_url : AdaUrl, ParseOptions; // @safe, nothrow and betterC compatible
import std.stdio : writeln; // need GC and throw exception

void main() @safe {
auto u = AdaUrl(ParseOptions("http://www.google:8080/love#drug"));
writeln("port: ", u.getPort);
writeln("hash: ", u.getHash);
writeln("pathname: ", u.getPathname);
writeln("href: ", u.getHref());
u.setPort("9999");
writeln("href: ", u.getHref); // empty '()' is optional
}
```

## Resources

- [Source code][source-code]
- [Dub - dub.pm][dub-registry]
- [Documentation - dpldocs.info][documentation]


[dub-registry]: http://ada-d.dub.pm
[documentation]: https://ada-d.dpldocs.info
[source-code]: https://github.com/kassane/ada-d
Loading