Skip to content

Commit ca43d7c

Browse files
feat: Added optional schemars-alpha feature to support (schemars 1.0-alpha releases) (#28)
1 parent 86b3003 commit ca43d7c

File tree

7 files changed

+92
-30
lines changed

7 files changed

+92
-30
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ jobs:
2424
test-all:
2525
runs-on: ubuntu-latest
2626
container:
27-
image: rust:1.66.0
27+
image: rust:1.70.0
2828
steps:
2929
- uses: actions/checkout@v3
3030
- uses: Swatinem/rust-cache@v1
@@ -35,7 +35,7 @@ jobs:
3535
clippy:
3636
runs-on: ubuntu-latest
3737
container:
38-
image: rust:1.66.0
38+
image: rust:1.70.0
3939
steps:
4040
- uses: actions/checkout@v3
4141
- uses: Swatinem/rust-cache@v1

Cargo.lock

Lines changed: 73 additions & 26 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,22 @@ license = "MIT OR Apache-2.0"
99
publish = true
1010

1111
[features]
12-
abi = ["borsh/unstable__schema", "schemars"]
12+
abi = ["borsh/unstable__schema", "schemars-stable"]
13+
abi-alpha = ["borsh/unstable__schema", "schemars-alpha"]
1314
# This feature was introduced for legacy reasons for nearcore, and MUST be avoided
1415
# https://github.com/near/nearcore/pull/4621#issuecomment-892099860
1516
internal_unstable = []
1617
default = []
18+
schemars = []
19+
schemars-stable = ["schemars", "dep:schemars-stable"]
20+
schemars-alpha = ["schemars", "dep:schemars-alpha"]
1721

1822
[dependencies]
1923
arbitrary = { version = "1", features = ["derive"] , optional = true }
2024
borsh = { version = "1.0.0", features = ["rc"], optional = true }
2125
serde = { version = "1.0.119", features = ["alloc", "derive", "rc"], optional = true }
22-
schemars = { version = "0.8", optional = true }
26+
schemars-stable = { version = "0.8.22", optional = true, package = "schemars" }
27+
schemars-alpha = { version = "1.0.0-alpha.17", optional = true, package = "schemars" }
2328

2429
[dev-dependencies]
2530
bolero = ">=0.8.0, <0.10.0"

src/account_id.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::{borrow::Cow, fmt, ops::Deref, str::FromStr};
22

33
use crate::{AccountIdRef, ParseAccountError};
4+
#[cfg(feature = "schemars")]
5+
use crate::schemars_exports::schemars;
46

57
/// NEAR Account Identifier.
68
///

src/account_id_ref.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
use std::borrow::Cow;
22

33
use crate::{AccountId, ParseAccountError};
4+
#[cfg(feature = "schemars")]
5+
use crate::schemars_exports::schemars;
46

57
/// Account identifier. This is the human readable UTF-8 string which is used internally to index
68
/// accounts on the network and their respective state.

src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
3838
mod errors;
3939

40+
mod schemars_exports;
4041
mod account_id;
4142
mod account_id_ref;
4243
#[cfg(feature = "borsh")]

src/schemars_exports.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#[cfg(all(feature = "schemars-alpha", not(feature = "schemars-stable")))]
2+
pub use schemars_alpha as schemars;
3+
4+
#[cfg(feature = "schemars-stable")]
5+
pub use schemars_stable as schemars;

0 commit comments

Comments
 (0)