From 3bf04fbeea0df0bd6759100c0801f0dc851b046f Mon Sep 17 00:00:00 2001 From: Renato Westphal Date: Mon, 8 Jul 2024 11:58:16 -0300 Subject: [PATCH] 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 --- .github/workflows/ci.yaml | 4 +- .gitmodules | 4 +- Cargo.toml | 16 +++---- README.md | 48 +++++++++---------- benches/data.rs | 4 +- examples/data_diff.rs | 4 +- examples/data_edit.rs | 4 +- examples/data_iteration.rs | 4 +- examples/data_json2xml.rs | 4 +- examples/schema_iteration.rs | 4 +- examples/schema_yang2yin.rs | 4 +- libyang2-sys/libyang | 1 - {libyang2-sys => libyang3-sys}/Cargo.toml | 18 +++---- {libyang2-sys => libyang3-sys}/LICENSE | 0 {libyang2-sys => libyang3-sys}/build.rs | 19 ++++---- libyang3-sys/libyang | 1 + ...ba28260f382d81cf8f4b91b24cd717b52324fc2.rs | 12 +++-- {libyang2-sys => libyang3-sys}/src/lib.rs | 2 +- {libyang2-sys => libyang3-sys}/wrapper.h | 0 src/context.rs | 6 +-- src/data.rs | 4 +- src/error.rs | 8 ++-- src/iter.rs | 8 ++-- src/lib.rs | 28 +++++------ src/schema.rs | 4 +- src/utils.rs | 2 +- tests/data.rs | 4 +- tests/schema.rs | 4 +- 28 files changed, 113 insertions(+), 108 deletions(-) delete mode 160000 libyang2-sys/libyang rename {libyang2-sys => libyang3-sys}/Cargo.toml (57%) rename {libyang2-sys => libyang3-sys}/LICENSE (100%) rename {libyang2-sys => libyang3-sys}/build.rs (92%) create mode 160000 libyang3-sys/libyang rename libyang2-sys/pre-generated-bindings/libyang2-4c733412e7173219166be7053940326a92699765.rs => libyang3-sys/pre-generated-bindings/libyang3-fba28260f382d81cf8f4b91b24cd717b52324fc2.rs (99%) rename {libyang2-sys => libyang3-sys}/src/lib.rs (88%) rename {libyang2-sys => libyang3-sys}/wrapper.h (100%) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index a6d34e1..c40e401 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -42,7 +42,7 @@ jobs: test: name: Tests and Coverage Report env: - yang2_rs: rust_ci_github_actions_workflow + yang_rs: rust_ci_github_actions_workflow CARGO_INCREMENTAL: 0 RUSTFLAGS: -Zprofile -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off -Zpanic_abort_tests -Cpanic=abort RUSTDOCFLAGS: -Cpanic=abort @@ -71,7 +71,7 @@ jobs: run: | cargo install cargo2junit grcov; cargo test --features bundled $CARGO_OPTIONS -- -Z unstable-options --format json | cargo2junit > results.xml; - grcov . -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --ignore "examples/*" --ignore "libyang2-sys/*" -o lcov.info; + grcov . -s . -t lcov --llvm --ignore-not-existing --ignore "/*" --ignore "tests/*" --ignore "examples/*" --ignore "libyang3-sys/*" -o lcov.info; - name: Upload test results uses: EnricoMi/publish-unit-test-result-action@v1 with: diff --git a/.gitmodules b/.gitmodules index 16d4a97..3594921 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,3 @@ -[submodule "libyang2-sys/libyang"] - path = libyang2-sys/libyang +[submodule "libyang3-sys/libyang"] + path = libyang3-sys/libyang url = https://github.com/CESNET/libyang.git diff --git a/Cargo.toml b/Cargo.toml index eca6c9f..4c99e26 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,19 +1,19 @@ [package] -name = "yang2" -version = "0.13.1" +name = "yang3" +version = "0.1.0" authors = ["Renato Westphal "] -description = "libyang2 bindings for Rust" +description = "libyang3 bindings for Rust" keywords = ["yang", "libyang"] edition = "2018" license = "MIT" -repository = "https://github.com/holo-routing/yang2-rs" -documentation = "https://docs.rs/yang2" +repository = "https://github.com/holo-routing/yang-rs" +documentation = "https://docs.rs/yang3" readme = "README.md" categories = ["parser-implementations"] exclude = ["assets/**"] [dependencies] -libyang2-sys = { path = "libyang2-sys", version = "0.9.0" } +libyang3-sys = { path = "libyang3-sys", version = "0.1.0" } bitflags = "2.5" num-traits = "0.2" num-derive = "0.4" @@ -33,5 +33,5 @@ harness = false [features] default = [] -use_bindgen = ["libyang2-sys/use_bindgen"] -bundled = ["libyang2-sys/bundled"] +bindgen = ["libyang3-sys/bindgen"] +bundled = ["libyang3-sys/bundled"] diff --git a/README.md b/README.md index c396884..09b9e49 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# yang2-rs +# yang-rs [![Crates.io][crates-badge]][crates-url] [![Documentation][docs-badge]][docs-url] @@ -6,41 +6,41 @@ [![Build Status][actions-badge]][actions-url] [![codecov][codecov-badge]][codecov-url] -[crates-badge]: https://img.shields.io/crates/v/yang2.svg -[crates-url]: https://crates.io/crates/yang2 -[docs-badge]: https://docs.rs/yang2/badge.svg -[docs-url]: https://docs.rs/yang2 +[crates-badge]: https://img.shields.io/crates/v/yang3.svg +[crates-url]: https://crates.io/crates/yang3 +[docs-badge]: https://docs.rs/yang3/badge.svg +[docs-url]: https://docs.rs/yang3 [mit-badge]: https://img.shields.io/badge/license-MIT-blue.svg -[mit-url]: https://github.com/holo-routing/yang2-rs/blob/master/LICENSE -[actions-badge]: https://github.com/holo-routing/yang2-rs/workflows/CI/badge.svg -[actions-url]: https://github.com/holo-routing/yang2-rs/actions?query=workflow%3ACI+branch%3Amaster -[codecov-badge]: https://codecov.io/gh/holo-routing/yang2-rs/branch/master/graph/badge.svg?token=1KE3JMHG0H -[codecov-url]: https://codecov.io/gh/holo-routing/yang2-rs +[mit-url]: https://github.com/holo-routing/yang-rs/blob/master/LICENSE +[actions-badge]: https://github.com/holo-routing/yang-rs/workflows/CI/badge.svg +[actions-url]: https://github.com/holo-routing/yang-rs/actions?query=workflow%3ACI+branch%3Amaster +[codecov-badge]: https://codecov.io/gh/holo-routing/yang-rs/branch/master/graph/badge.svg?token=1KE3JMHG0H +[codecov-url]: https://codecov.io/gh/holo-routing/yang-rs -Rust bindings for the [libyang2] library. +Rust bindings for the [libyang] library. -For raw FFI bindings for libyang2, see [libyang2-sys]. +For raw FFI bindings for libyang, see [libyang-sys]. -[libyang2]: https://github.com/CESNET/libyang/tree/libyang2 -[libyang2-sys]: https://github.com/holo-routing/yang2-rs/tree/master/libyang2-sys +[libyang]: https://github.com/CESNET/libyang/tree/libyang +[libyang-sys]: https://github.com/holo-routing/yang-rs/tree/master/libyang-sys #### Cargo.toml ```toml [dependencies] -yang2 = "0.13" +yang3 = "0.1" ``` ## Design Goals -* Provide high-level bindings for libyang2 using idiomatic Rust +* Provide high-level bindings for libyang using idiomatic Rust * Leverage Rust's ownership system to detect API misuse problems at compile time * Automatic resource management * Zero-cost abstractions ## Feature flags -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: -* **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. +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: +* **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. * Additional build requirements: *cc 1.0*, *cmake 0.1*, a C compiler and CMake. -* **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. +* **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. * Additional build requirements: *bindgen 0.68.0* ## Example @@ -50,8 +50,8 @@ it to the XML format: ```rust,no_run use std::sync::Arc; use std::fs::File; -use yang2::context::{Context, ContextFlags}; -use yang2::data::{ +use yang3::context::{Context, ContextFlags}; +use yang3::data::{ Data, DataFormat, DataParserFlags, DataPrinterFlags, DataTree, DataValidationFlags, }; @@ -98,14 +98,14 @@ fn main() -> std::io::Result<()> { Note the `NO_STATE` flag passed to `parse_file` since the example json file does not contain state data. More examples can be found [here][examples]. -[examples]: https://github.com/holo-routing/yang2-rs/tree/master/examples +[examples]: https://github.com/holo-routing/yang-rs/tree/master/examples ## License This project is licensed under the [MIT license]. -[MIT license]: https://github.com/holo-routing/yang2-rs/blob/master/LICENSE +[MIT license]: https://github.com/holo-routing/yang-rs/blob/master/LICENSE ### Contributing -Bug reports and pull requests are welcome on GitHub at https://github.com/holo-routing/yang2-rs. +Bug reports and pull requests are welcome on GitHub at https://github.com/holo-routing/yang-rs. diff --git a/benches/data.rs b/benches/data.rs index e18fa55..5d02479 100644 --- a/benches/data.rs +++ b/benches/data.rs @@ -1,8 +1,8 @@ use std::sync::Arc; use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion}; -use yang2::context::{Context, ContextFlags}; -use yang2::data::{Data, DataDiffFlags, DataTree, DataValidationFlags}; +use yang3::context::{Context, ContextFlags}; +use yang3::data::{Data, DataDiffFlags, DataTree, DataValidationFlags}; static SEARCH_DIR: &str = "./assets/yang/"; diff --git a/examples/data_diff.rs b/examples/data_diff.rs index cc06b90..f5891cc 100644 --- a/examples/data_diff.rs +++ b/examples/data_diff.rs @@ -1,6 +1,6 @@ use std::sync::Arc; -use yang2::context::{Context, ContextFlags}; -use yang2::data::{ +use yang3::context::{Context, ContextFlags}; +use yang3::data::{ Data, DataDiffFlags, DataFormat, DataParserFlags, DataPrinterFlags, DataTree, DataValidationFlags, }; diff --git a/examples/data_edit.rs b/examples/data_edit.rs index de2b87f..ad05ca4 100644 --- a/examples/data_edit.rs +++ b/examples/data_edit.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::sync::Arc; -use yang2::context::{Context, ContextFlags}; -use yang2::data::{ +use yang3::context::{Context, ContextFlags}; +use yang3::data::{ Data, DataFormat, DataParserFlags, DataPrinterFlags, DataTree, DataValidationFlags, }; diff --git a/examples/data_iteration.rs b/examples/data_iteration.rs index 77abfc5..011d767 100644 --- a/examples/data_iteration.rs +++ b/examples/data_iteration.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::sync::Arc; -use yang2::context::{Context, ContextFlags}; -use yang2::data::{ +use yang3::context::{Context, ContextFlags}; +use yang3::data::{ Data, DataFormat, DataParserFlags, DataTree, DataValidationFlags, }; diff --git a/examples/data_json2xml.rs b/examples/data_json2xml.rs index c626ae8..343d436 100644 --- a/examples/data_json2xml.rs +++ b/examples/data_json2xml.rs @@ -1,7 +1,7 @@ use std::fs::File; use std::sync::Arc; -use yang2::context::{Context, ContextFlags}; -use yang2::data::{ +use yang3::context::{Context, ContextFlags}; +use yang3::data::{ Data, DataFormat, DataParserFlags, DataPrinterFlags, DataTree, DataValidationFlags, }; diff --git a/examples/schema_iteration.rs b/examples/schema_iteration.rs index 0a487f3..3cac61b 100644 --- a/examples/schema_iteration.rs +++ b/examples/schema_iteration.rs @@ -1,5 +1,5 @@ -use yang2::context::{Context, ContextFlags}; -use yang2::schema::SchemaPathFormat; +use yang3::context::{Context, ContextFlags}; +use yang3::schema::SchemaPathFormat; static SEARCH_DIR: &str = "./assets/yang/"; static MODULE_NAME: &str = "ietf-isis"; diff --git a/examples/schema_yang2yin.rs b/examples/schema_yang2yin.rs index a6f2211..6fcb9b1 100644 --- a/examples/schema_yang2yin.rs +++ b/examples/schema_yang2yin.rs @@ -1,5 +1,5 @@ -use yang2::context::{Context, ContextFlags}; -use yang2::schema::{SchemaOutputFormat, SchemaPrinterFlags}; +use yang3::context::{Context, ContextFlags}; +use yang3::schema::{SchemaOutputFormat, SchemaPrinterFlags}; static SEARCH_DIR: &str = "./assets/yang/"; static MODULE_NAME: &str = "ietf-routing"; diff --git a/libyang2-sys/libyang b/libyang2-sys/libyang deleted file mode 160000 index 4c73341..0000000 --- a/libyang2-sys/libyang +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 4c733412e7173219166be7053940326a92699765 diff --git a/libyang2-sys/Cargo.toml b/libyang3-sys/Cargo.toml similarity index 57% rename from libyang2-sys/Cargo.toml rename to libyang3-sys/Cargo.toml index 2e5f59f..219e34b 100644 --- a/libyang2-sys/Cargo.toml +++ b/libyang3-sys/Cargo.toml @@ -1,12 +1,12 @@ [package] -name = "libyang2-sys" -version = "0.9.0" +name = "libyang3-sys" +version = "0.1.0" authors = ["Renato Westphal "] -description = "Raw FFI bindings for libyang2" +description = "Raw FFI bindings for libyang3" keywords = ["yang", "libyang"] edition = "2018" license = "MIT" -documentation = "https://docs.rs/libyang2-sys" +documentation = "https://docs.rs/libyang3-sys" categories = ["external-ffi-bindings"] [dependencies] @@ -21,8 +21,8 @@ pkg-config = "0.3.27" # Use pre-generated FFI bindings default = [] # Generate FFI bindings dynamically. -# For this to work libyang2 needs to be installed in the system. -use_bindgen = ["bindgen"] -# Bundle libyang2 C files into a static archive linked to this crate. -# This removes the libyang2 dynamic link dependency. -bundled = ["cc", "cmake"] +# For this to work libyang3 needs to be installed in the system. +bindgen = ["dep:bindgen"] +# Bundle libyang3 C files into a static archive linked to this crate. +# This removes the libyang3 dynamic link dependency. +bundled = ["dep:cc", "dep:cmake"] diff --git a/libyang2-sys/LICENSE b/libyang3-sys/LICENSE similarity index 100% rename from libyang2-sys/LICENSE rename to libyang3-sys/LICENSE diff --git a/libyang2-sys/build.rs b/libyang3-sys/build.rs similarity index 92% rename from libyang2-sys/build.rs rename to libyang3-sys/build.rs index fba55f1..a9e0a22 100644 --- a/libyang2-sys/build.rs +++ b/libyang3-sys/build.rs @@ -3,9 +3,9 @@ use std::path::PathBuf; fn main() { let dst = PathBuf::from(env::var("OUT_DIR").unwrap()); - let out_file = dst.join("libyang2.rs"); + let out_file = dst.join("libyang3.rs"); - #[cfg(feature = "use_bindgen")] + #[cfg(feature = "bindgen")] { // Generate Rust FFI to libfrr. println!("cargo:rerun-if-changed=wrapper.h"); @@ -14,21 +14,21 @@ fn main() { .derive_default(true) .default_enum_style(bindgen::EnumVariation::ModuleConsts) .generate() - .expect("Unable to generate libyang2 bindings"); + .expect("Unable to generate libyang3 bindings"); bindings .write_to_file(out_file) - .expect("Couldn't write libyang2 bindings!"); + .expect("Couldn't write libyang3 bindings!"); } - #[cfg(not(feature = "use_bindgen"))] + #[cfg(not(feature = "bindgen"))] { let mut pregen_bindings = PathBuf::new(); pregen_bindings.push(env::var("CARGO_MANIFEST_DIR").unwrap()); pregen_bindings.push("pre-generated-bindings"); pregen_bindings - .push("libyang2-4c733412e7173219166be7053940326a92699765.rs"); + .push("libyang3-fba28260f382d81cf8f4b91b24cd717b52324fc2.rs"); std::fs::copy(&pregen_bindings, &out_file) - .expect("Unable to copy pre-generated libyang2 bindings"); + .expect("Unable to copy pre-generated libyang3 bindings"); } #[cfg(feature = "bundled")] @@ -46,11 +46,12 @@ fn main() { // Run cmake. let cmake_dst = cmake::build("libyang"); - // Build libyang2. + // Build libyang3. let mut build = cc::Build::new(); build .include(format!("{}/build/compat", cmake_dst.display())) .include(format!("{}/build/src", cmake_dst.display())) + .include(format!("{}/build/libyang", cmake_dst.display())) .include("libyang/src") .include("libyang/src/plugins_exts") .file("libyang/compat/compat.c") @@ -130,7 +131,7 @@ fn main() { .file("libyang/src/xpath.c") .warnings(false); - build.compile("yang2"); + build.compile("yang3"); println!("cargo:root={}", env::var("OUT_DIR").unwrap()); if let Err(e) = pkg_config::Config::new().probe("libpcre2-8") { println!("cargo:warning=failed to find pcre2 library with pkg-config: {}", e); diff --git a/libyang3-sys/libyang b/libyang3-sys/libyang new file mode 160000 index 0000000..fba2826 --- /dev/null +++ b/libyang3-sys/libyang @@ -0,0 +1 @@ +Subproject commit fba28260f382d81cf8f4b91b24cd717b52324fc2 diff --git a/libyang2-sys/pre-generated-bindings/libyang2-4c733412e7173219166be7053940326a92699765.rs b/libyang3-sys/pre-generated-bindings/libyang3-fba28260f382d81cf8f4b91b24cd717b52324fc2.rs similarity index 99% rename from libyang2-sys/pre-generated-bindings/libyang2-4c733412e7173219166be7053940326a92699765.rs rename to libyang3-sys/pre-generated-bindings/libyang3-fba28260f382d81cf8f4b91b24cd717b52324fc2.rs index 9f70e3e..783cd6c 100644 --- a/libyang2-sys/pre-generated-bindings/libyang2-4c733412e7173219166be7053940326a92699765.rs +++ b/libyang3-sys/pre-generated-bindings/libyang3-fba28260f382d81cf8f4b91b24cd717b52324fc2.rs @@ -1349,8 +1349,9 @@ pub const LYD_VALHINT_BOOLEAN: u32 = 32; pub const LYD_VALHINT_EMPTY: u32 = 64; pub const LYD_NODEHINT_LIST: u32 = 128; pub const LYD_NODEHINT_LEAFLIST: u32 = 256; -pub const LYD_HINT_DATA: u32 = 499; -pub const LYD_HINT_SCHEMA: u32 = 511; +pub const LYD_NODEHINT_CONTAINER: u32 = 512; +pub const LYD_HINT_DATA: u32 = 1011; +pub const LYD_HINT_SCHEMA: u32 = 1023; pub const LYD_NEW_VAL_OUTPUT: u32 = 1; pub const LYD_NEW_VAL_STORE_ONLY: u32 = 2; pub const LYD_NEW_VAL_BIN: u32 = 4; @@ -25082,6 +25083,9 @@ extern "C" { extern "C" { pub fn lyd_node_schema(node: *const lyd_node) -> *const lysc_node; } +extern "C" { + pub fn lyd_meta_is_internal(meta: *const lyd_meta) -> ly_bool; +} extern "C" { pub fn lyd_new_inner( parent: *mut lyd_node, @@ -26764,7 +26768,7 @@ impl Default for lysp_stmt { #[derive(Debug, Copy, Clone)] pub struct lysp_ext_substmt { pub stmt: ly_stmt::Type, - pub storage: *mut ::std::os::raw::c_void, + pub storage: u64, } #[test] fn bindgen_test_layout_lysp_ext_substmt() { @@ -26998,7 +27002,7 @@ impl Default for lysp_ext_instance { #[derive(Debug, Copy, Clone)] pub struct lysc_ext_substmt { pub stmt: ly_stmt::Type, - pub storage: *mut ::std::os::raw::c_void, + pub storage: u64, } #[test] fn bindgen_test_layout_lysc_ext_substmt() { diff --git a/libyang2-sys/src/lib.rs b/libyang3-sys/src/lib.rs similarity index 88% rename from libyang2-sys/src/lib.rs rename to libyang3-sys/src/lib.rs index b0c3417..082d62a 100644 --- a/libyang2-sys/src/lib.rs +++ b/libyang3-sys/src/lib.rs @@ -10,4 +10,4 @@ deref_nullptr, )] -include!(concat!(env!("OUT_DIR"), "/libyang2.rs")); +include!(concat!(env!("OUT_DIR"), "/libyang3.rs")); diff --git a/libyang2-sys/wrapper.h b/libyang3-sys/wrapper.h similarity index 100% rename from libyang2-sys/wrapper.h rename to libyang3-sys/wrapper.h diff --git a/src/context.rs b/src/context.rs index 723e0da..e0f00f3 100644 --- a/src/context.rs +++ b/src/context.rs @@ -1,5 +1,5 @@ // -// Copyright (c) The yang2-rs Core Contributors +// Copyright (c) The yang-rs Core Contributors // // SPDX-License-Identifier: MIT // @@ -19,13 +19,13 @@ use crate::error::{Error, Result}; use crate::iter::{SchemaModules, Set}; use crate::schema::{SchemaModule, SchemaNode}; use crate::utils::*; -use libyang2_sys as ffi; +use libyang3_sys as ffi; /// Context of the YANG schemas. /// /// [Official C documentation] /// -/// [Official C documentation]: https://netopeer.liberouter.org/doc/libyang/libyang2/html/howto_context.html +/// [Official C documentation]: https://netopeer.liberouter.org/doc/libyang/master/html/howto_context.html #[derive(Debug, PartialEq)] pub struct Context { pub(crate) raw: *mut ffi::ly_ctx, diff --git a/src/data.rs b/src/data.rs index 91208c2..1853dd2 100644 --- a/src/data.rs +++ b/src/data.rs @@ -1,5 +1,5 @@ // -// Copyright (c) The yang2-rs Core Contributors +// Copyright (c) The yang-rs Core Contributors // // SPDX-License-Identifier: MIT // @@ -20,7 +20,7 @@ use crate::iter::{ }; use crate::schema::{DataValue, SchemaModule, SchemaNode, SchemaNodeKind}; use crate::utils::*; -use libyang2_sys as ffi; +use libyang3_sys as ffi; /// YANG data tree. #[derive(Debug)] diff --git a/src/error.rs b/src/error.rs index 37feed3..c68b642 100644 --- a/src/error.rs +++ b/src/error.rs @@ -1,17 +1,17 @@ // -// Copyright (c) The yang2-rs Core Contributors +// Copyright (c) The yang-rs Core Contributors // // SPDX-License-Identifier: MIT // use crate::context::Context; use crate::utils::*; -use libyang2_sys as ffi; +use libyang3_sys as ffi; -/// A convenience wrapper around `Result` for `yang2::Error`. +/// A convenience wrapper around `Result` for `yang3::Error`. pub type Result = std::result::Result; -/// Enum listing possible errors from yang2-rs. +/// Enum listing possible errors from yang3. #[derive(Debug, Eq, PartialEq)] pub struct Error { pub errcode: ffi::LY_ERR::Type, diff --git a/src/iter.rs b/src/iter.rs index c16b540..c404ad1 100644 --- a/src/iter.rs +++ b/src/iter.rs @@ -1,5 +1,5 @@ // -// Copyright (c) The yang2-rs Core Contributors +// Copyright (c) The yang-rs Core Contributors // // SPDX-License-Identifier: MIT // @@ -10,7 +10,7 @@ use crate::context::Context; use crate::data::Metadata; use crate::schema::SchemaModule; use crate::utils::Binding; -use libyang2_sys as ffi; +use libyang3_sys as ffi; /// Common methods used by multiple data and schema node iterators. #[doc(hidden)] @@ -73,8 +73,8 @@ where /// An iterator over an array of nodes or substatements. /// -/// This is a safe wrapper around libyang2's -/// [sized arrays](https://netopeer.liberouter.org/doc/libyang/libyang2/html/howto_structures.html#sizedarrays). +/// This is a safe wrapper around libyang3's +/// [sized arrays](https://netopeer.liberouter.org/doc/libyang/master/html/howto_structures.html). #[derive(Debug)] pub struct Array<'a, S: Binding<'a>> { context: &'a Context, diff --git a/src/lib.rs b/src/lib.rs index 9c20034..12b55fe 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,41 +1,41 @@ // -// Copyright (c) The yang2-rs Core Contributors +// Copyright (c) The yang-rs Core Contributors // // SPDX-License-Identifier: MIT // -//! Rust bindings for the [libyang2] library. +//! Rust bindings for the [libyang3] library. //! -//! For raw FFI bindings for libyang2, see [libyang2-sys]. +//! For raw FFI bindings for libyang3, see [libyang3-sys]. //! -//! [libyang2]: https://github.com/CESNET/libyang/tree/libyang2 -//! [libyang2-sys]: https://github.com/holo-routing/yang2-rs/tree/master/libyang2-sys +//! [libyang3]: https://github.com/CESNET/libyang/tree/master +//! [libyang3-sys]: https://github.com/holo-routing/yang-rs/tree/master/libyang3-sys //! //! ## Design Goals -//! * Provide high-level bindings for libyang2 using idiomatic Rust +//! * Provide high-level bindings for libyang3 using idiomatic Rust //! * Leverage Rust's ownership system to detect API misuse problems at compile //! time //! * Automatic resource management //! * Zero-cost abstractions //! //! ## Feature flags -//! By default, yang2-rs uses pre-generated FFI bindings and uses dynamic -//! linking to load libyang2. The following feature flags, however, can be used +//! By default, yang-rs uses pre-generated FFI bindings and uses dynamic +//! linking to load libyang3. The following feature flags, however, can be used //! to change that behavior: -//! * **bundled**: instructs cargo to download and build libyang2 from the +//! * **bundled**: instructs cargo to download and build libyang3 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 +//! this crate. This feature can be used when having a libyang3 dynamic link //! dependency isn't desirable. //! * Additional build requirements: *cc 1.0*, *cmake 0.1*, a C compiler and //! CMake. //! * **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. -//! * Additional build requirements: *bindgen 0.55.0* +//! libyang3 versions. +//! * Additional build requirements: *bindgen 0.68.0* //! //! ## Examples //! -//! See +//! See mod error; @@ -48,4 +48,4 @@ pub mod utils; pub use crate::error::Error; // Re-export the raw FFI bindings for convenience. -pub use libyang2_sys as ffi; +pub use libyang3_sys as ffi; diff --git a/src/schema.rs b/src/schema.rs index 94e21f7..a94fb8e 100644 --- a/src/schema.rs +++ b/src/schema.rs @@ -1,5 +1,5 @@ // -// Copyright (c) The yang2-rs Core Contributors +// Copyright (c) The yang-rs Core Contributors // // SPDX-License-Identifier: MIT // @@ -19,7 +19,7 @@ use crate::context::Context; use crate::error::{Error, Result}; use crate::iter::{Ancestors, Array, NodeIterable, Set, Siblings, Traverse}; use crate::utils::*; -use libyang2_sys as ffi; +use libyang3_sys as ffi; /// Available YANG schema tree structures representing YANG module. #[derive(Clone, Debug)] diff --git a/src/utils.rs b/src/utils.rs index 4214934..71461e1 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -1,5 +1,5 @@ // -// Copyright (c) The yang2-rs Core Contributors +// Copyright (c) The yang-rs Core Contributors // // SPDX-License-Identifier: MIT // diff --git a/tests/data.rs b/tests/data.rs index 4c921ac..e1eb704 100644 --- a/tests/data.rs +++ b/tests/data.rs @@ -1,7 +1,7 @@ use std::collections::BTreeSet; use std::sync::Arc; -use yang2::context::{Context, ContextFlags}; -use yang2::data::{ +use yang3::context::{Context, ContextFlags}; +use yang3::data::{ Data, DataDiff, DataDiffFlags, DataFormat, DataImplicitFlags, DataOperation, DataParserFlags, DataPrinterFlags, DataTree, DataValidationFlags, diff --git a/tests/schema.rs b/tests/schema.rs index 55e15bc..3ff5b59 100644 --- a/tests/schema.rs +++ b/tests/schema.rs @@ -1,5 +1,5 @@ -use yang2::context::{Context, ContextFlags}; -use yang2::schema::{ +use yang3::context::{Context, ContextFlags}; +use yang3::schema::{ DataValue, DataValueType, SchemaNodeKind, SchemaPathFormat, };