Skip to content

Commit

Permalink
Add separate README files to get nicer pages on crates.io
Browse files Browse the repository at this point in the history
  • Loading branch information
einarmo committed Jan 24, 2025
1 parent 1a93e8c commit 58186f2
Show file tree
Hide file tree
Showing 26 changed files with 422 additions and 35 deletions.
5 changes: 2 additions & 3 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Tutorials / user guides are still work in progress.

The API documentation is generated from the latest published crates. This may be some way behind current development.

<a href="https://docs.rs/opcua"><img src="https://docs.rs/opcua/badge.svg"></img></a>
<a href="https://docs.rs/async-opcua"><img src="https://docs.rs/async-opcua/badge.svg"></img></a>

# Samples

Expand Down
5 changes: 2 additions & 3 deletions async-opcua-client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repository = "https://github.com/freeopcua/async-opcua"
license = "MPL-2.0"
keywords = ["opcua", "opc", "ua"]
categories = ["embedded", "network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua/"
readme = "README.md"
documentation = "https://docs.rs/async-opcua-client/"
edition = "2021"

[lib]
Expand All @@ -33,4 +33,3 @@ async-opcua-types = { path = "../async-opcua-types", version = "0.14.0" }
async-opcua-core = { path = "../async-opcua-core", version = "0.14.0" }
async-opcua-crypto = { path = "../async-opcua-crypto", version = "0.14.0" }
async-opcua-nodes = { path = "../async-opcua-nodes", version = "0.14.0" }
async-opcua-xml = { path = "../async-opcua-xml", optional = true, version = "0.14.0" }
61 changes: 61 additions & 0 deletions async-opcua-client/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Async OPC-UA Client

Part of [async-opcua](https://crates.io/crates/async-opcua), a general purpose OPC-UA library in rust.

This library defines a fully capable async OPC-UA client based on tokio. You will need a tokio runtime to use this client at all, as it depends on tokio for network and I/O.

The OPC UA Client module contains the functionality necessary for a client to connect to an OPC UA server, authenticate itself, send messages, receive responses, get values, browse the address space and provide callbacks for things to be propagated to the client.

Once the `Client` is created it can connect to a server by creating a `Session`. Multiple sessions can be created from the same client.

To connect to a session, you can either use one of the `connect_*` methods on the `Client`, or the `SessionBuilder` which is more flexible.

Once connected, you will get a `Session` object, and an `EventLoop`. The event loop must be continuously polled while you use the session, you can do this manually, to monitor the state of the connection, or you can just spawn it on a tokio task using `event_loop.spawn()`.

The `Session` object contains methods for each OPC-UA service as of version 1.05 of the standard. Each service may be called directly with its corresponding method, i.e.

```rust
session.read(...).await?
```

or by using the request builder:

```rust
Read::new(&session).nodes_to_read(...).send(session.channel()).await?
```

By using the request builder, it is also possible to retry requests by using `Session::send_with_retry`.

## Example

```rust
#[tokio::main]
async fn main() {
let mut client = ClientBuilder::new()
.application_name("My First Client")
.application_uri("urn:MyFirstClient")
.create_sample_keypair(true)
.trust_server_certs(false)
.session_retry_limit(3)
.client().unwrap();
// Create an endpoint. The EndpointDescription can be made from a tuple consisting of
// the endpoint url, security policy, message security mode and user token policy.
let endpoint: EndpointDescription = (
"opc.tcp://localhost:4855/",
"None",
MessageSecurityMode::None,
UserTokenPolicy::anonymous()
).into();
// Create the session and event loop
let (session, event_loop) = client.connect_to_matching_endpoint(endpoint, IdentityToken::Anonymous).await.unwrap();
let handle = event_loop.spawn();
session.wait_for_connection().await;
// From here you can call services on the session...
// It is good practice to exit the session when you are done, since
// OPC-UA servers may keep clients that exit uncleanly alive for some time.
let _ = session_c.disconnect().await;
handle.await.unwrap();
}
```

See [simple client](../samples/simple-client/) for a slightly more elaborate example.
6 changes: 3 additions & 3 deletions async-opcua-codegen/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[package]
name = "async-opcua-codegen"
version = "0.13.0"
version = "0.14.0"
edition = "2021"
description = "OPC UA code generation library"
authors = ["Einar Omang <[email protected]>"]
homepage = "https://github.com/freeopcua/async-opcua"
repository = "https://github.com/freeopcua/async-opcua"
license = "MPL-2.0"
keywords = ["opcua", "opc", "ua"]
readme = "../README.md"
documentation = "https://docs.rs/opcua/"
readme = "README.md"
documentation = "https://docs.rs/async-opcua/"

[lib]
name = "opcua_codegen"
Expand Down
9 changes: 9 additions & 0 deletions async-opcua-codegen/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Async OPC-UA Core

Part of [async-opcua](https://crates.io/crates/async-opcua), a general purpose OPC-UA library in rust.

This is a command line tool to generate code for use with the async-opcua client and server libraries.

To use, define a [YAML](https://yaml.org/) configuration file with a list of code gen targets, including OPC-UA BSD (Binary Schema Definition) files, XSD (XML Schema Definition) files, and NodeSet2.xml files.

See the [custom-codegen](../samples/custom-codegen/) sample for an example of how this can be done.
4 changes: 2 additions & 2 deletions async-opcua-core-namespace/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repository = "https://github.com/freeopcua/async-opcua"
license = "MPL-2.0"
keywords = ["opcua", "opc", "ua"]
categories = ["embedded", "network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua/"
readme = "README.md"
documentation = "https://docs.rs/async-opcua-core-namespace/"
edition = "2021"

[lib]
Expand Down
7 changes: 7 additions & 0 deletions async-opcua-core-namespace/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Async OPC-UA Core Namespace

Part of [async-opcua](https://crates.io/crates/async-opcua), a general purpose OPC-UA library in rust.

This library contains generated code for nodes and events defined in the core OPC-UA standard. It is intended to be used with [async-opcua-server](https://crates.io/crates/async-opcua-server), to define the core node manager.

All OPC-UA servers must define the core namespace, which is primarily the core type hierarchy. Version 1.05 of the OPC-UA standard was used to generate this code, using `async-opcua-codegen`.
4 changes: 2 additions & 2 deletions async-opcua-core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repository = "https://github.com/freeopcua/async-opcua"
license = "MPL-2.0"
keywords = ["opcua", "opc", "ua"]
categories = ["embedded", "network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua/"
readme = "README.md"
documentation = "https://docs.rs/async-opcua-core/"
edition = "2021"

[lib]
Expand Down
14 changes: 14 additions & 0 deletions async-opcua-core/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Async OPC-UA Core

Part of [async-opcua](https://crates.io/crates/async-opcua), a general purpose OPC-UA library in rust.

This library contains common types used by the server and client parts of the `async-opcua` library.

You will typically use either the client or server, and rarely use this library directly.

`async-opcua-core` covers a few different areas of shared functionality.

- The `RequestMessage` and `ResponseMessage` enums, which discriminate over the possible messages in an OPC-UA request and response.
- Core message types such as `HelloMessage`, `AcknowledgeMessage`, `MessageChunk`, etc. and components of these.
- The low-level implementation of the opc/tcp protocol.
- The `SecureChannel` type, which uses [async-opcua-crypto](https://crates.io/crates/async-opcua-crypto) to encrypt OPC-UA messages.
4 changes: 2 additions & 2 deletions async-opcua-crypto/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repository = "https://github.com/freeopcua/async-opcua"
license = "MPL-2.0"
keywords = ["opcua", "opc", "ua"]
categories = ["embedded", "network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua/"
readme = "README.md"
documentation = "https://docs.rs/async-opcua-crypto/"
edition = "2021"

[lib]
Expand Down
17 changes: 17 additions & 0 deletions async-opcua-crypto/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Async OPC-UA Crypto

Part of [async-opcua](https://crates.io/crates/async-opcua), a general purpose OPC-UA library in rust.

This defines common cryptographic tooling for the OPC-UA protocol using libraries from [Rust Crypto](https://github.com/rustcrypto).

Currently supported security policies:

- `Basic256` (Deprecated)
- `Basic128Rsa15` (Deprecated)
- `Basic256Sha256` (Deprecated)
- `Aes256Sha256RsaPss`
- `Aes128Sha256Oaep`

There's also some general tooling for working with and generating X509 Certificates, as well as support for the _legacy_ password encryption/decryption scheme in OPC-UA.

You are unlikely to want to use this library directly, but it is used in both the server and client parts `async-opcua`.
4 changes: 2 additions & 2 deletions async-opcua-macros/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repository = "https://github.com/freeopcua/async-opcua"
license = "MPL-2.0"
keywords = ["opcua", "opc", "ua"]
categories = ["embedded", "network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua/"
readme = "README.md"
documentation = "https://docs.rs/async-opcua-macros/"
edition = "2021"

[features]
Expand Down
21 changes: 21 additions & 0 deletions async-opcua-macros/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Async OPC-UA Macros

Part of [async-opcua](https://crates.io/crates/async-opcua), a general purpose OPC-UA library in rust.

This defines a number of utility macros for encoding, decoding, and defining types to help write server and client software.

Currently defines:

- `Event`, a macro for deriving the `Event` trait on custom event types.
- `EventField`, a macro for deriving the `EventField` trait, used for types that can be part of OPC-UA events.
- `FromXml`, with the `"xml"` feature. Derives conversion from XML objects in `NodeSet2` files.
- `JsonEncodable`, with the `"json"` feature. Derives streaming serialization using OPC-UA JSON.
- `JsonDecodable`, with the `"json"` feature. Derives streaming deserialization using OPC-UA JSON.
- `BinaryEncodable`, derives streaming serialization using OPC-UA Binary.
- `BinaryDecodable`, derives streaming deserialization using OPC-UA Binary.
- `UaEnum`, derives the `UaEnum` and a few other traits to make it easier to define custom OPC-UA enums.

## Features

- `json`, adds the `JsonEncodable` and `JsonDecodable` macros.
- `xml`, adds the `FromXml` macro.
4 changes: 2 additions & 2 deletions async-opcua-nodes/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repository = "https://github.com/freeopcua/async-opcua"
license = "MPL-2.0"
keywords = ["opcua", "opc", "ua"]
categories = ["embedded", "network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua/"
readme = "README.md"
documentation = "https://docs.rs/async-opcua-nodes/"
edition = "2021"

[lib]
Expand Down
13 changes: 13 additions & 0 deletions async-opcua-nodes/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# Async OPC-UA Nodes

Part of [async-opcua](https://crates.io/crates/async-opcua), a general purpose OPC-UA library in rust.

This library defines types used mainly in the [async-opcua-server](https://crates.io/crates/async-opcua-server) library as part of in-memory node managers, but also utilities for importing `NodeSet2` XML files to Rust.

Primarily, this library defines a type for each OPC-UA NodeClass `Object`, `Variable`, `Method`, `View`, `ObjectType`, `VariableType`, `DataType`, and `ReferenceType`, as well as builders for all of these. There's also a common enum over all of these `NodeType`.

A few other common types are also defined here, such as the `TypeTree` trait, used in the server to provide the server with a view of all the types defined on the server, and the `NodeSet2Import` type, used to import `NodeSet2` files into memory.

## Features

- `xml` adds support for reading NodeSet2 XML files into `NodeType`.
11 changes: 7 additions & 4 deletions async-opcua-server/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,15 @@ repository = "https://github.com/freeopcua/async-opcua"
license = "MPL-2.0"
keywords = ["opcua", "opc", "ua"]
categories = ["embedded", "network-programming"]
readme = "../README.md"
documentation = "https://docs.rs/opcua/"
readme = "README.md"
documentation = "https://docs.rs/async-opcua-server/"
edition = "2021"

[lib]
name = "opcua_server"

[features]
default = ["discovery-server-registration", "generated-address-space"]
default = ["generated-address-space"]
# Includes all the code to populate the address space with the default node set. This is something that embedded
# systems may or may not require.
generated-address-space = ["async-opcua-core-namespace"]
Expand All @@ -38,7 +38,6 @@ log = { workspace = true }
parking_lot = { workspace = true }
regex = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tokio = { workspace = true }
tokio-util = { workspace = true }
postcard = { workspace = true }
Expand All @@ -51,3 +50,7 @@ async-opcua-nodes = { path = "../async-opcua-nodes", version = "0.14.0" }

async-opcua-client = { path = "../async-opcua-client", optional = true, version = "0.14.0" }
async-opcua-core-namespace = { path = "../async-opcua-core-namespace", optional = true, version = "0.14.0" }


[dev-dependencies]
async-opcua-server = { path = ".", features = ["discovery-server-registration", "json"]}
Loading

0 comments on commit 58186f2

Please sign in to comment.