Skip to content

Commit 3bf04fb

Browse files
committed
Update to libyang 3.1.0 and release yang3 0.1.0
Support for libyang v2 will continue in the yang2 branch. Signed-off-by: Renato Westphal <[email protected]>
1 parent b3aa9dd commit 3bf04fb

28 files changed

+113
-108
lines changed

.github/workflows/ci.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
test:
4343
name: Tests and Coverage Report
4444
env:
45-
yang2_rs: rust_ci_github_actions_workflow
45+
yang_rs: rust_ci_github_actions_workflow
4646
CARGO_INCREMENTAL: 0
4747
RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort
4848
RUSTDOCFLAGS: -Cpanic=abort
@@ -71,7 +71,7 @@ jobs:
7171
run: |
7272
cargo install cargo2junit grcov;
7373
cargo test --features bundled $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml;
74-
grcov . -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --ignore "examples/*" --ignore "libyang2-sys/*" -o lcov.info;
74+
grcov . -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --ignore "examples/*" --ignore "libyang3-sys/*" -o lcov.info;
7575
- name: Upload test results
7676
uses: EnricoMi/publish-unit-test-result-action@v1
7777
with:

.gitmodules

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
[submodule "libyang2-sys/libyang"]
2-
path = libyang2-sys/libyang
1+
[submodule "libyang3-sys/libyang"]
2+
path = libyang3-sys/libyang
33
url = https://github.com/CESNET/libyang.git

Cargo.toml

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
[package]
2-
name = "yang2"
3-
version = "0.13.1"
2+
name = "yang3"
3+
version = "0.1.0"
44
authors = ["Renato Westphal <[email protected]>"]
5-
description = "libyang2 bindings for Rust"
5+
description = "libyang3 bindings for Rust"
66
keywords = ["yang", "libyang"]
77
edition = "2018"
88
license = "MIT"
9-
repository = "https://github.com/holo-routing/yang2-rs"
10-
documentation = "https://docs.rs/yang2"
9+
repository = "https://github.com/holo-routing/yang-rs"
10+
documentation = "https://docs.rs/yang3"
1111
readme = "README.md"
1212
categories = ["parser-implementations"]
1313
exclude = ["assets/**"]
1414

1515
[dependencies]
16-
libyang2-sys = { path = "libyang2-sys", version = "0.9.0" }
16+
libyang3-sys = { path = "libyang3-sys", version = "0.1.0" }
1717
bitflags = "2.5"
1818
num-traits = "0.2"
1919
num-derive = "0.4"
@@ -33,5 +33,5 @@ harness = false
3333

3434
[features]
3535
default = []
36-
use_bindgen = ["libyang2-sys/use_bindgen"]
37-
bundled = ["libyang2-sys/bundled"]
36+
bindgen = ["libyang3-sys/bindgen"]
37+
bundled = ["libyang3-sys/bundled"]

README.md

+24-24
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
1-
# yang2-rs
1+
# yang-rs
22

33
[![Crates.io][crates-badge]][crates-url]
44
[![Documentation][docs-badge]][docs-url]
55
[![MIT licensed][mit-badge]][mit-url]
66
[![Build Status][actions-badge]][actions-url]
77
[![codecov][codecov-badge]][codecov-url]
88

9-
[crates-badge]: https://img.shields.io/crates/v/yang2.svg
10-
[crates-url]: https://crates.io/crates/yang2
11-
[docs-badge]: https://docs.rs/yang2/badge.svg
12-
[docs-url]: https://docs.rs/yang2
9+
[crates-badge]: https://img.shields.io/crates/v/yang3.svg
10+
[crates-url]: https://crates.io/crates/yang3
11+
[docs-badge]: https://docs.rs/yang3/badge.svg
12+
[docs-url]: https://docs.rs/yang3
1313
[mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg
14-
[mit-url]: https://github.com/holo-routing/yang2-rs/blob/master/LICENSE
15-
[actions-badge]: https://github.com/holo-routing/yang2-rs/workflows/CI/badge.svg
16-
[actions-url]: https://github.com/holo-routing/yang2-rs/actions?query=workflow%3ACI+branch%3Amaster
17-
[codecov-badge]: https://codecov.io/gh/holo-routing/yang2-rs/branch/master/graph/badge.svg?token=1KE3JMHG0H
18-
[codecov-url]: https://codecov.io/gh/holo-routing/yang2-rs
14+
[mit-url]: https://github.com/holo-routing/yang-rs/blob/master/LICENSE
15+
[actions-badge]: https://github.com/holo-routing/yang-rs/workflows/CI/badge.svg
16+
[actions-url]: https://github.com/holo-routing/yang-rs/actions?query=workflow%3ACI+branch%3Amaster
17+
[codecov-badge]: https://codecov.io/gh/holo-routing/yang-rs/branch/master/graph/badge.svg?token=1KE3JMHG0H
18+
[codecov-url]: https://codecov.io/gh/holo-routing/yang-rs
1919

20-
Rust bindings for the [libyang2] library.
20+
Rust bindings for the [libyang] library.
2121

22-
For raw FFI bindings for libyang2, see [libyang2-sys].
22+
For raw FFI bindings for libyang, see [libyang-sys].
2323

24-
[libyang2]: https://github.com/CESNET/libyang/tree/libyang2
25-
[libyang2-sys]: https://github.com/holo-routing/yang2-rs/tree/master/libyang2-sys
24+
[libyang]: https://github.com/CESNET/libyang/tree/libyang
25+
[libyang-sys]: https://github.com/holo-routing/yang-rs/tree/master/libyang-sys
2626

2727
#### Cargo.toml
2828

2929
```toml
3030
[dependencies]
31-
yang2 = "0.13"
31+
yang3 = "0.1"
3232
```
3333
## Design Goals
34-
* Provide high-level bindings for libyang2 using idiomatic Rust
34+
* Provide high-level bindings for libyang using idiomatic Rust
3535
* Leverage Rust's ownership system to detect API misuse problems at compile time
3636
* Automatic resource management
3737
* Zero-cost abstractions
3838

3939
## Feature flags
40-
By default, yang2-rs uses pre-generated FFI bindings and uses dynamic linking to load libyang2. The following feature flags, however, can be used to change that behavior:
41-
* **bundled**: instructs cargo to download and build libyang2 from the sources. The resulting objects are grouped into a static archive linked to this crate. This feature can be used when having a libyang2 dynamic link dependency isn't desirable.
40+
By default, yang-rs uses pre-generated FFI bindings and uses dynamic linking to load libyang. The following feature flags, however, can be used to change that behavior:
41+
* **bundled**: instructs cargo to download and build libyang from the sources. The resulting objects are grouped into a static archive linked to this crate. This feature can be used when having a libyang dynamic link dependency isn't desirable.
4242
* Additional build requirements: *cc 1.0*, *cmake 0.1*, a C compiler and CMake.
43-
* **use_bindgen**: generate new C FFI bindings dynamically instead of using the pre-generated ones. Useful when updating this crate to use newer libyang2 versions.
43+
* **use_bindgen**: generate new C FFI bindings dynamically instead of using the pre-generated ones. Useful when updating this crate to use newer libyang versions.
4444
* Additional build requirements: *bindgen 0.68.0*
4545

4646
## Example
@@ -50,8 +50,8 @@ it to the XML format:
5050
```rust,no_run
5151
use std::sync::Arc;
5252
use std::fs::File;
53-
use yang2::context::{Context, ContextFlags};
54-
use yang2::data::{
53+
use yang3::context::{Context, ContextFlags};
54+
use yang3::data::{
5555
Data, DataFormat, DataParserFlags, DataPrinterFlags, DataTree,
5656
DataValidationFlags,
5757
};
@@ -98,14 +98,14 @@ fn main() -> std::io::Result<()> {
9898
Note the `NO_STATE` flag passed to `parse_file` since the example json file does not contain state data.
9999
More examples can be found [here][examples].
100100

101-
[examples]: https://github.com/holo-routing/yang2-rs/tree/master/examples
101+
[examples]: https://github.com/holo-routing/yang-rs/tree/master/examples
102102

103103
## License
104104

105105
This project is licensed under the [MIT license].
106106

107-
[MIT license]: https://github.com/holo-routing/yang2-rs/blob/master/LICENSE
107+
[MIT license]: https://github.com/holo-routing/yang-rs/blob/master/LICENSE
108108

109109
### Contributing
110110

111-
Bug reports and pull requests are welcome on GitHub at https://github.com/holo-routing/yang2-rs.
111+
Bug reports and pull requests are welcome on GitHub at https://github.com/holo-routing/yang-rs.

benches/data.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
use std::sync::Arc;
22

33
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion};
4-
use yang2::context::{Context, ContextFlags};
5-
use yang2::data::{Data, DataDiffFlags, DataTree, DataValidationFlags};
4+
use yang3::context::{Context, ContextFlags};
5+
use yang3::data::{Data, DataDiffFlags, DataTree, DataValidationFlags};
66

77
static SEARCH_DIR: &str = "./assets/yang/";
88

examples/data_diff.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::sync::Arc;
2-
use yang2::context::{Context, ContextFlags};
3-
use yang2::data::{
2+
use yang3::context::{Context, ContextFlags};
3+
use yang3::data::{
44
Data, DataDiffFlags, DataFormat, DataParserFlags, DataPrinterFlags,
55
DataTree, DataValidationFlags,
66
};

examples/data_edit.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fs::File;
22
use std::sync::Arc;
3-
use yang2::context::{Context, ContextFlags};
4-
use yang2::data::{
3+
use yang3::context::{Context, ContextFlags};
4+
use yang3::data::{
55
Data, DataFormat, DataParserFlags, DataPrinterFlags, DataTree,
66
DataValidationFlags,
77
};

examples/data_iteration.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fs::File;
22
use std::sync::Arc;
3-
use yang2::context::{Context, ContextFlags};
4-
use yang2::data::{
3+
use yang3::context::{Context, ContextFlags};
4+
use yang3::data::{
55
Data, DataFormat, DataParserFlags, DataTree, DataValidationFlags,
66
};
77

examples/data_json2xml.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use std::fs::File;
22
use std::sync::Arc;
3-
use yang2::context::{Context, ContextFlags};
4-
use yang2::data::{
3+
use yang3::context::{Context, ContextFlags};
4+
use yang3::data::{
55
Data, DataFormat, DataParserFlags, DataPrinterFlags, DataTree,
66
DataValidationFlags,
77
};

examples/schema_iteration.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use yang2::context::{Context, ContextFlags};
2-
use yang2::schema::SchemaPathFormat;
1+
use yang3::context::{Context, ContextFlags};
2+
use yang3::schema::SchemaPathFormat;
33

44
static SEARCH_DIR: &str = "./assets/yang/";
55
static MODULE_NAME: &str = "ietf-isis";

examples/schema_yang2yin.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
use yang2::context::{Context, ContextFlags};
2-
use yang2::schema::{SchemaOutputFormat, SchemaPrinterFlags};
1+
use yang3::context::{Context, ContextFlags};
2+
use yang3::schema::{SchemaOutputFormat, SchemaPrinterFlags};
33

44
static SEARCH_DIR: &str = "./assets/yang/";
55
static MODULE_NAME: &str = "ietf-routing";

libyang2-sys/libyang

-1
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
[package]
2-
name = "libyang2-sys"
3-
version = "0.9.0"
2+
name = "libyang3-sys"
3+
version = "0.1.0"
44
authors = ["Renato Westphal <[email protected]>"]
5-
description = "Raw FFI bindings for libyang2"
5+
description = "Raw FFI bindings for libyang3"
66
keywords = ["yang", "libyang"]
77
edition = "2018"
88
license = "MIT"
9-
documentation = "https://docs.rs/libyang2-sys"
9+
documentation = "https://docs.rs/libyang3-sys"
1010
categories = ["external-ffi-bindings"]
1111

1212
[dependencies]
@@ -21,8 +21,8 @@ pkg-config = "0.3.27"
2121
# Use pre-generated FFI bindings
2222
default = []
2323
# Generate FFI bindings dynamically.
24-
# For this to work libyang2 needs to be installed in the system.
25-
use_bindgen = ["bindgen"]
26-
# Bundle libyang2 C files into a static archive linked to this crate.
27-
# This removes the libyang2 dynamic link dependency.
28-
bundled = ["cc", "cmake"]
24+
# For this to work libyang3 needs to be installed in the system.
25+
bindgen = ["dep:bindgen"]
26+
# Bundle libyang3 C files into a static archive linked to this crate.
27+
# This removes the libyang3 dynamic link dependency.
28+
bundled = ["dep:cc", "dep:cmake"]
File renamed without changes.

libyang2-sys/build.rs libyang3-sys/build.rs

+10-9
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ use std::path::PathBuf;
33

44
fn main() {
55
let dst = PathBuf::from(env::var("OUT_DIR").unwrap());
6-
let out_file = dst.join("libyang2.rs");
6+
let out_file = dst.join("libyang3.rs");
77

8-
#[cfg(feature = "use_bindgen")]
8+
#[cfg(feature = "bindgen")]
99
{
1010
// Generate Rust FFI to libfrr.
1111
println!("cargo:rerun-if-changed=wrapper.h");
@@ -14,21 +14,21 @@ fn main() {
1414
.derive_default(true)
1515
.default_enum_style(bindgen::EnumVariation::ModuleConsts)
1616
.generate()
17-
.expect("Unable to generate libyang2 bindings");
17+
.expect("Unable to generate libyang3 bindings");
1818
bindings
1919
.write_to_file(out_file)
20-
.expect("Couldn't write libyang2 bindings!");
20+
.expect("Couldn't write libyang3 bindings!");
2121
}
22-
#[cfg(not(feature = "use_bindgen"))]
22+
#[cfg(not(feature = "bindgen"))]
2323
{
2424
let mut pregen_bindings = PathBuf::new();
2525
pregen_bindings.push(env::var("CARGO_MANIFEST_DIR").unwrap());
2626
pregen_bindings.push("pre-generated-bindings");
2727
pregen_bindings
28-
.push("libyang2-4c733412e7173219166be7053940326a92699765.rs");
28+
.push("libyang3-fba28260f382d81cf8f4b91b24cd717b52324fc2.rs");
2929

3030
std::fs::copy(&pregen_bindings, &out_file)
31-
.expect("Unable to copy pre-generated libyang2 bindings");
31+
.expect("Unable to copy pre-generated libyang3 bindings");
3232
}
3333

3434
#[cfg(feature = "bundled")]
@@ -46,11 +46,12 @@ fn main() {
4646
// Run cmake.
4747
let cmake_dst = cmake::build("libyang");
4848

49-
// Build libyang2.
49+
// Build libyang3.
5050
let mut build = cc::Build::new();
5151
build
5252
.include(format!("{}/build/compat", cmake_dst.display()))
5353
.include(format!("{}/build/src", cmake_dst.display()))
54+
.include(format!("{}/build/libyang", cmake_dst.display()))
5455
.include("libyang/src")
5556
.include("libyang/src/plugins_exts")
5657
.file("libyang/compat/compat.c")
@@ -130,7 +131,7 @@ fn main() {
130131
.file("libyang/src/xpath.c")
131132
.warnings(false);
132133

133-
build.compile("yang2");
134+
build.compile("yang3");
134135
println!("cargo:root={}", env::var("OUT_DIR").unwrap());
135136
if let Err(e) = pkg_config::Config::new().probe("libpcre2-8") {
136137
println!("cargo:warning=failed to find pcre2 library with pkg-config: {}", e);

libyang3-sys/libyang

Submodule libyang added at fba2826

libyang2-sys/pre-generated-bindings/libyang2-4c733412e7173219166be7053940326a92699765.rs libyang3-sys/pre-generated-bindings/libyang3-fba28260f382d81cf8f4b91b24cd717b52324fc2.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -1349,8 +1349,9 @@ pub const LYD_VALHINT_BOOLEAN: u32 = 32;
13491349
pub const LYD_VALHINT_EMPTY: u32 = 64;
13501350
pub const LYD_NODEHINT_LIST: u32 = 128;
13511351
pub const LYD_NODEHINT_LEAFLIST: u32 = 256;
1352-
pub const LYD_HINT_DATA: u32 = 499;
1353-
pub const LYD_HINT_SCHEMA: u32 = 511;
1352+
pub const LYD_NODEHINT_CONTAINER: u32 = 512;
1353+
pub const LYD_HINT_DATA: u32 = 1011;
1354+
pub const LYD_HINT_SCHEMA: u32 = 1023;
13541355
pub const LYD_NEW_VAL_OUTPUT: u32 = 1;
13551356
pub const LYD_NEW_VAL_STORE_ONLY: u32 = 2;
13561357
pub const LYD_NEW_VAL_BIN: u32 = 4;
@@ -25082,6 +25083,9 @@ extern "C" {
2508225083
extern "C" {
2508325084
pub fn lyd_node_schema(node: *const lyd_node) -> *const lysc_node;
2508425085
}
25086+
extern "C" {
25087+
pub fn lyd_meta_is_internal(meta: *const lyd_meta) -> ly_bool;
25088+
}
2508525089
extern "C" {
2508625090
pub fn lyd_new_inner(
2508725091
parent: *mut lyd_node,
@@ -26764,7 +26768,7 @@ impl Default for lysp_stmt {
2676426768
#[derive(Debug, Copy, Clone)]
2676526769
pub struct lysp_ext_substmt {
2676626770
pub stmt: ly_stmt::Type,
26767-
pub storage: *mut ::std::os::raw::c_void,
26771+
pub storage: u64,
2676826772
}
2676926773
#[test]
2677026774
fn bindgen_test_layout_lysp_ext_substmt() {
@@ -26998,7 +27002,7 @@ impl Default for lysp_ext_instance {
2699827002
#[derive(Debug, Copy, Clone)]
2699927003
pub struct lysc_ext_substmt {
2700027004
pub stmt: ly_stmt::Type,
27001-
pub storage: *mut ::std::os::raw::c_void,
27005+
pub storage: u64,
2700227006
}
2700327007
#[test]
2700427008
fn bindgen_test_layout_lysc_ext_substmt() {

libyang2-sys/src/lib.rs libyang3-sys/src/lib.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,4 @@
1010
deref_nullptr,
1111
)]
1212

13-
include!(concat!(env!("OUT_DIR"), "/libyang2.rs"));
13+
include!(concat!(env!("OUT_DIR"), "/libyang3.rs"));
File renamed without changes.

src/context.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//
2-
// Copyright (c) The yang2-rs Core Contributors
2+
// Copyright (c) The yang-rs Core Contributors
33
//
44
// SPDX-License-Identifier: MIT
55
//
@@ -19,13 +19,13 @@ use crate::error::{Error, Result};
1919
use crate::iter::{SchemaModules, Set};
2020
use crate::schema::{SchemaModule, SchemaNode};
2121
use crate::utils::*;
22-
use libyang2_sys as ffi;
22+
use libyang3_sys as ffi;
2323

2424
/// Context of the YANG schemas.
2525
///
2626
/// [Official C documentation]
2727
///
28-
/// [Official C documentation]: https://netopeer.liberouter.org/doc/libyang/libyang2/html/howto_context.html
28+
/// [Official C documentation]: https://netopeer.liberouter.org/doc/libyang/master/html/howto_context.html
2929
#[derive(Debug, PartialEq)]
3030
pub struct Context {
3131
pub(crate) raw: *mut ffi::ly_ctx,

0 commit comments

Comments
 (0)