Skip to content
This repository has been archived by the owner on Jun 9, 2024. It is now read-only.

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
rj00a committed May 2, 2024
0 parents commit 83fd4fc
Show file tree
Hide file tree
Showing 36 changed files with 12,923 additions and 0 deletions.
9 changes: 9 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Please see the documentation for all configuration options:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates

version: 2
updates:
- package-ecosystem: "cargo"
directory: "/"
schedule:
interval: "weekly"
97 changes: 97 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
name: Rust

on:
push:
branches: [ "main" ]
pull_request:

env:
CARGO_TERM_COLOR: always

jobs:
fmt:
name: Formatting
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3

- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
with:
toolchain: "nightly"
components: "rustfmt"

- name: cargo fmt
run: cargo fmt --all -- --check

docs:
name: Documentation
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3

- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]

- name: Validate documentation
run: RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps --all-features --document-private-items

clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3

- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
with:
toolchain: "nightly"
components: "clippy"

- name: Clippy
run: cargo clippy --workspace --no-deps --all-features --all-targets -- -D warnings

tests:
name: Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3

- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]

- name: All features
run: cargo test --workspace --all-features --all-targets

- name: No default features
run: cargo test --workspace --no-default-features --all-targets

miri:
name: Miri Tests
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3

- name: Setup Rust toolchain and cache
uses: actions-rust-lang/[email protected]
with:
toolchain: "nightly"
components: "miri"

- name: Run tests
run: MIRIFLAGS='-Zmiri-tree-borrows' cargo miri test --workspace --all-features --all-targets

typos:
name: Typos
runs-on: ubuntu-latest
steps:
- name: Checkout Actions Repository
uses: actions/checkout@v3

- name: Check for spelling errors
uses: crate-ci/[email protected]
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/target
/Cargo.lock
116 changes: 116 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,116 @@
[workspace]
members = ["valence_nbt", "java_string"]
resolver = "2"

[workspace.package]
edition = "2021"
license = "MIT"
repository = "https://github.com/valence-rs/valence_nbt"

[workspace.lints.rust]
elided_lifetimes_in_paths = "allow" # Warned by `future_incompatible`.
future_incompatible = "warn"
missing_debug_implementations = "warn"
# missing_docs = "warn"
nonstandard_style = "warn"
rust_2018_idioms = "warn"
trivial_numeric_casts = "warn"
unreachable_pub = "warn"
unused_import_braces = "warn"
unused_lifetimes = "warn"

[workspace.lints.clippy]
alloc_instead_of_core = "warn"
as_ptr_cast_mut = "warn"
as_underscore = "warn"
bool_to_int_with_if = "warn"
case_sensitive_file_extension_comparisons = "warn"
cast_lossless = "warn"
checked_conversions = "warn"
cloned_instead_of_copied = "warn"
copy_iterator = "warn"
dbg_macro = "warn"
doc_link_with_quotes = "warn"
doc_markdown = "warn"
empty_enum_variants_with_brackets = "warn"
empty_structs_with_brackets = "warn"
explicit_deref_methods = "warn"
explicit_into_iter_loop = "warn"
explicit_iter_loop = "warn"
filter_map_next = "warn"
flat_map_option = "warn"
format_push_string = "warn"
from_iter_instead_of_collect = "warn"
get_unwrap = "warn"
if_then_some_else_none = "warn"
ignored_unit_patterns = "warn"
impl_trait_in_params = "warn"
implicit_clone = "warn"
inconsistent_struct_constructor = "warn"
inefficient_to_string = "warn"
infinite_loop = "warn"
into_iter_without_iter = "warn"
invalid_upcast_comparisons = "warn"
iter_filter_is_ok = "warn"
iter_filter_is_some = "warn"
iter_not_returning_iterator = "warn"
iter_over_hash_type = "warn" # Requires justification
iter_without_into_iter = "warn"
large_stack_arrays = "warn"
large_types_passed_by_value = "warn"
macro_use_imports = "warn"
manual_assert = "warn"
manual_instant_elapsed = "warn"
manual_is_variant_and = "warn"
manual_let_else = "warn"
manual_ok_or = "warn"
manual_string_new = "warn"
map_unwrap_or = "warn"
match_bool = "warn"
match_wildcard_for_single_variants = "warn"
mismatching_type_param_order = "warn"
missing_fields_in_debug = "warn"
mixed_read_write_in_expression = "warn"
mod_module_files = "warn"
multiple_inherent_impl = "warn"
mut_mut = "warn"
mutex_atomic = "warn"
needless_bitwise_bool = "warn"
needless_continue = "warn"
needless_for_each = "warn"
needless_raw_string_hashes = "warn"
needless_raw_strings = "warn"
negative_feature_names = "warn"
no_mangle_with_rust_abi = "warn"
option_as_ref_cloned = "warn"
pub_underscore_fields = "warn"
rc_buffer = "warn"
rc_mutex = "warn"
redundant_else = "warn"
redundant_feature_names = "warn"
ref_patterns = "warn"
rest_pat_in_fully_bound_structs = "warn"
semicolon_outside_block = "warn"
str_to_string = "warn"
string_lit_chars_any = "warn"
string_to_string = "warn"
struct_field_names = "warn"
tests_outside_test_module = "warn"
todo = "warn"
trivially_copy_pass_by_ref = "warn"
try_err = "warn"
# undocumented_unsafe_blocks = "warn"
uninlined_format_args = "warn"
unnecessary_join = "warn"
# unnecessary_safety_doc = "warn"
unnecessary_self_imports = "warn"
unneeded_field_pattern = "warn"
unnested_or_patterns = "warn"
unseparated_literal_suffix = "warn"
unused_self = "warn"
used_underscore_binding = "warn"
wildcard_dependencies = "warn"
zero_sized_map_values = "warn"

[workspace.lints.rustdoc]
unescaped_backticks = "warn"
21 changes: 21 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Ryan Johnson

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# valence_nbt

A library for encoding and decoding Minecraft's [Named Binary Tag] (NBT)
format.

[Named Binary Tag]: https://minecraft.wiki/w/NBT_format

# Features

- `binary`: Serialize and deserialize in Java edition's binary format.
- `snbt`: Serialize and deserialize in "stringified" format.
- `preserve_order`: Preserve the order of fields in [`Compound`]s during insertion and deletion. The iterators on `Compound` then implement `DoubleEndedIterator`.
- `serde`: Adds support for [`serde`](https://docs.rs/serde/latest/serde/)
- `java_string`: Adds support for Java-compatible strings via the `java_string` crate.
18 changes: 18 additions & 0 deletions java_string/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
[package]
name = "java_string"
version = "0.1.2"
description = "An implementation of Java strings, tolerant of invalid UTF-16 encoding"
keywords = ["java", "string", "utf16"]
edition.workspace = true
repository.workspace = true
license.workspace = true

[features]
serde = ["dep:serde"]

[dependencies]
serde = { version = "1.0.200", optional = true }

[lints]
workspace = true

17 changes: 17 additions & 0 deletions java_string/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# java_string

Check failure on line 1 in java_string/README.md

View workflow job for this annotation

GitHub Actions / Clippy

item in documentation is missing backticks

An implementation of Java strings, tolerant of invalid UTF-16 encoding.
This allows for round-trip serialization of all Java strings, including those which contain invalid UTF-16, while still
being able to perform useful operations on those strings.

These Java strings use the UTF-8 encoding, with the modification that surrogate code points (code points between U+D800
and U+DFFF inclusive) are allowed. This allows for zero-cost conversion from Rust strings to Java strings. This modified
encoding is known as "semi-UTF-8" throughout the codebase. Similarly, this crate introduces a `JavaCodePoint` type which
is analogous to `char`, except that surrogate code points are allowed.

This crate is mostly undocumented, because most methods are entirely analogous to those of the same name in Rust's
strings. Please refer to the `std` documentation.

# Features

- `serde` Adds support for [`serde`](https://docs.rs/serde/latest/serde/)
Loading

0 comments on commit 83fd4fc

Please sign in to comment.