Skip to content

Commit

Permalink
68.13.9 - rust
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedor committed Feb 16, 2024
1 parent 4f1966e commit 36910f9
Show file tree
Hide file tree
Showing 583 changed files with 39,094 additions and 70,432 deletions.
2 changes: 1 addition & 1 deletion third_party/rust/bincode/.cargo-checksum.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"files":{"Cargo.toml":"eda034c33e46b4b2ec6e6af6f1ddbcbf6642eaa88b46a1692ecc8acc7df9bf53","LICENSE.md":"90d7e062634054e6866d3c81e6a2b3058a840e6af733e98e80bdfe1a7dec6912","readme.md":"2ff3f54e6efd24b38f981b539be77438c10b9b8f67cad41ca2188396f95bcde8","src/config.rs":"2a6da0f5f95794add175c0a37e2a293f6d4c5932fc43f41492f646a98bf58aa9","src/de/mod.rs":"1da6149812e2d2c4ae8f9fdf7fc5bf85376d2f82da9a9311b0c45eff4033b71d","src/de/read.rs":"f8c5f2466c632f062e6fe55734d27c8fc7566c0894b610f012d8835af1810628","src/error.rs":"00a7a4de5cf1cc4a28dcf44c5c3ff607887baf41d5410b76468088963257b783","src/internal.rs":"6c827579a325e02bc7df8403965616b970b0f9b9763896ed938e719309a681b4","src/lib.rs":"9af9d73dcc1fc19240b8855ed521d38ae963e6685627e5d3eebf9acf40424aa3","src/ser/mod.rs":"b544c335a39a9b702772d586caa44f0e6febae3a0a109625fcee8ac68fc95645"},"package":"bda13183df33055cbb84b847becce220d392df502ebe7a4a78d7021771ed94d0"}
{"files":{"Cargo.toml":"16c6c5374dd14773571dfab3254557ca0e3f7810e1fb27df6e27c2112e16c605","LICENSE.md":"90d7e062634054e6866d3c81e6a2b3058a840e6af733e98e80bdfe1a7dec6912","readme.md":"8d9ee7f575a20798e09471169ff3b5e3dea6ab74c50d2128cfc77f4074e97149","src/config.rs":"e3e6e264cdc736c442b9299d7ad39475457f0c69d2ea8fa0de14f8120c5f3023","src/de/mod.rs":"c431445d27366eaa05553fe1eb5dee320e87b7145b26fe50a56568fc83ccfe95","src/de/read.rs":"e188e291aef8c4ce41552390a28caacb26188c796e25c912d9730ad411a4abeb","src/error.rs":"ce6617bf8523392e6fc8b853b7768899a229b6b78dabc2918c0e2dd3f846aa01","src/internal.rs":"55a69c335cf15038eb76f7ba71b0828b20ee1d16adbc5e10e2087efbb74c55ea","src/lib.rs":"41258f970098e3b0421daf9fbaff34efa716039632f5d1b6409e22fe473c5775","src/ser/mod.rs":"323ca31c66188ba952faf6de111c91fe551a27ebc522c10a3cfe2e5348a74390"},"package":"5753e2a71534719bf3f4e57006c3a4f0d2c672a4b676eec84161f763eca87dbf"}
23 changes: 14 additions & 9 deletions third_party/rust/bincode/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g. crates.io) dependencies
# to registry (e.g., crates.io) dependencies
#
# If you believe there's an error in this file please file an
# issue against the rust-lang/cargo repository. If you're
Expand All @@ -12,24 +12,29 @@

[package]
name = "bincode"
version = "1.0.0"
version = "1.2.1"
authors = ["Ty Overby <[email protected]>", "Francesco Mazzoli <[email protected]>", "David Tolnay <[email protected]>", "Daniel Griffen"]
exclude = ["logo.png", "tests/*", "examples/*", ".gitignore", ".travis.yml", "changelist.org"]
exclude = ["logo.png", "tests/*", "examples/*", ".gitignore", ".travis.yml"]
publish = true
description = "A binary serialization / deserialization strategy that uses Serde for transforming structs into bytes and vice versa!"
documentation = "https://docs.rs/bincode"
readme = "./readme.md"
keywords = ["binary", "encode", "decode", "serialize", "deserialize"]
categories = ["network-programming"]
categories = ["encoding", "network-programming"]
license = "MIT"
repository = "https://github.com/TyOverby/bincode"
repository = "https://github.com/servo/bincode"
[dependencies.byteorder]
version = "1.2.0"
version = "1.3.0"

[dependencies.serde]
version = "^1.0.27"
version = "1.0.63"
[dev-dependencies.serde_bytes]
version = "^0.10.3"
version = "0.11"

[dev-dependencies.serde_derive]
version = "^1.0.27"
version = "1.0.27"

[features]
i128 = []
[badges.travis-ci]
repository = "servo/bincode"
22 changes: 9 additions & 13 deletions third_party/rust/bincode/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

<img align="right" src="./logo.png" />

[![Build Status](https://travis-ci.org/TyOverby/bincode.svg)](https://travis-ci.org/TyOverby/bincode)
[![Build Status](https://travis-ci.com/servo/bincode.svg)](https://travis-ci.com/servo/bincode)
[![](https://meritbadge.herokuapp.com/bincode)](https://crates.io/crates/bincode)
[![](https://img.shields.io/badge/license-MIT-blue.svg)](http://opensource.org/licenses/MIT)
[![](https://img.shields.io/badge/license-MIT-blue.svg)](https://opensource.org/licenses/MIT)

A compact encoder / decoder pair that uses a binary zero-fluff encoding scheme.
The size of the encoded object will be the same or smaller than the size that
Expand All @@ -13,25 +13,22 @@ the object takes up in memory in a running Rust program.
In addition to exposing two simple functions
(one that encodes to `Vec<u8>`, and one that decodes from `&[u8]`),
binary-encode exposes a Reader/Writer API that makes it work
perfectly with other stream-based apis such as rust files, network streams,
perfectly with other stream-based APIs such as Rust files, network streams,
and the [flate2-rs](https://github.com/alexcrichton/flate2-rs) compression
library.

## [Api Documentation](http://docs.rs/bincode/)
## [API Documentation](https://docs.rs/bincode/)

## Bincode in the wild

* [google/tarpc](https://github.com/google/tarpc): Bincode is used to serialize and deserialize networked RPC messages.
* [servo/webrender](https://github.com/servo/webrender): Bincode records webrender API calls for record/replay-style graphics debugging.
* [servo/ipc-channel](https://github.com/servo/ipc-channel): Ipc-Channel uses Bincode to send structs between processes using a channel-like API.
* [servo/ipc-channel](https://github.com/servo/ipc-channel): IPC-Channel uses Bincode to send structs between processes using a channel-like API.

## Example
```rust
#[macro_use]
extern crate serde_derive;
extern crate bincode;

use bincode::{serialize, deserialize, Infinite};
```rust
use serde::{Serialize, Deserialize};

#[derive(Serialize, Deserialize, PartialEq, Debug)]
struct Entity {
Expand All @@ -45,18 +42,17 @@ struct World(Vec<Entity>);
fn main() {
let world = World(vec![Entity { x: 0.0, y: 4.0 }, Entity { x: 10.0, y: 20.5 }]);

let encoded: Vec<u8> = serialize(&world, Infinite).unwrap();
let encoded: Vec<u8> = bincode::serialize(&world).unwrap();

// 8 bytes for the length of the vector, 4 bytes per float.
assert_eq!(encoded.len(), 8 + 4 * 4);

let decoded: World = deserialize(&encoded[..]).unwrap();
let decoded: World = bincode::deserialize(&encoded[..]).unwrap();

assert_eq!(world, decoded);
}
```


## Details

The encoding (and thus decoding) proceeds unsurprisingly -- primitive
Expand Down
88 changes: 70 additions & 18 deletions third_party/rust/bincode/src/config.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
use super::internal::{Bounded, Infinite, SizeLimit};
use ::error::Result;
use byteorder::{BigEndian, ByteOrder, LittleEndian, NativeEndian};
use {DeserializerAcceptor, SerializerAcceptor};
use de::read::BincodeRead;
use error::Result;
use serde;
use std::io::{Write, Read};
use std::io::{Read, Write};
use std::marker::PhantomData;
use de::read::BincodeRead;
use {DeserializerAcceptor, SerializerAcceptor};

use self::LimitOption::*;
use self::EndianOption::*;
use self::LimitOption::*;

struct DefaultOptions(Infinite);

Expand Down Expand Up @@ -95,6 +95,7 @@ enum EndianOption {
///
/// When a byte limit is set, bincode will return `Err` on any deserialization that goes over the limit, or any
/// serialization that goes over the limit.
#[derive(Clone)]
pub struct Config {
limit: LimitOption,
endian: EndianOption,
Expand All @@ -110,7 +111,6 @@ pub(crate) struct WithOtherEndian<O: Options, E: ByteOrder> {
_endian: PhantomData<E>,
}


impl<O: Options, L: SizeLimit> WithOtherLimit<O, L> {
#[inline(always)]
pub(crate) fn new(options: O, limit: L) -> WithOtherLimit<O, L> {
Expand Down Expand Up @@ -179,7 +179,7 @@ macro_rules! config_map {
$call
}
}
}
};
}

impl Config {
Expand Down Expand Up @@ -217,7 +217,7 @@ impl Config {
/// Sets the endianness to big-endian
#[inline(always)]
pub fn big_endian(&mut self) -> &mut Self {
self.endian= EndianOption::Big;
self.endian = EndianOption::Big;
self
}

Expand Down Expand Up @@ -245,7 +245,11 @@ impl Config {
/// If the serialization would take more bytes than allowed by the size limit, an error
/// is returned and *no bytes* will be written into the `Writer`
#[inline(always)]
pub fn serialize_into<W: Write, T: ?Sized + serde::Serialize>(&self, w: W, t: &T) -> Result<()> {
pub fn serialize_into<W: Write, T: ?Sized + serde::Serialize>(
&self,
w: W,
t: &T,
) -> Result<()> {
config_map!(self, opts => ::internal::serialize_into(w, t, opts))
}

Expand All @@ -258,38 +262,85 @@ impl Config {
/// TODO: document
#[doc(hidden)]
#[inline(always)]
pub fn deserialize_in_place<'a, R, T: >(&self, reader: R, place: &mut T) -> Result<()>
pub fn deserialize_in_place<'a, R, T>(&self, reader: R, place: &mut T) -> Result<()>
where
R: BincodeRead<'a>,
T: serde::de::Deserialize<'a>
T: serde::de::Deserialize<'a>,
{
config_map!(self, opts => ::internal::deserialize_in_place(reader, opts, place))
}

/// Deserializes a slice of bytes with state `seed` using this configuration.
#[inline(always)]
pub fn deserialize_seed<'a, T: serde::de::DeserializeSeed<'a>>(
&self,
seed: T,
bytes: &'a [u8],
) -> Result<T::Value> {
config_map!(self, opts => ::internal::deserialize_seed(seed, bytes, opts))
}

/// Deserializes an object directly from a `Read`er using this configuration
///
/// If this returns an `Error`, `reader` may be in an invalid state.
#[inline(always)]
pub fn deserialize_from<R: Read, T: serde::de::DeserializeOwned>(&self, reader: R) -> Result<T> {
pub fn deserialize_from<R: Read, T: serde::de::DeserializeOwned>(
&self,
reader: R,
) -> Result<T> {
config_map!(self, opts => ::internal::deserialize_from(reader, opts))
}

/// Deserializes an object directly from a `Read`er with state `seed` using this configuration
///
/// If this returns an `Error`, `reader` may be in an invalid state.
#[inline(always)]
pub fn deserialize_from_seed<'a, R: Read, T: serde::de::DeserializeSeed<'a>>(
&self,
seed: T,
reader: R,
) -> Result<T::Value> {
config_map!(self, opts => ::internal::deserialize_from_seed(seed, reader, opts))
}

/// Deserializes an object from a custom `BincodeRead`er using the default configuration.
/// It is highly recommended to use `deserialize_from` unless you need to implement
/// `BincodeRead` for performance reasons.
///
/// If this returns an `Error`, `reader` may be in an invalid state.
#[inline(always)]
pub fn deserialize_from_custom<'a, R: BincodeRead<'a>, T: serde::de::DeserializeOwned>(&self, reader: R) -> Result<T> {
pub fn deserialize_from_custom<'a, R: BincodeRead<'a>, T: serde::de::DeserializeOwned>(
&self,
reader: R,
) -> Result<T> {
config_map!(self, opts => ::internal::deserialize_from_custom(reader, opts))
}

/// Deserializes an object from a custom `BincodeRead`er with state `seed` using the default
/// configuration. It is highly recommended to use `deserialize_from` unless you need to
/// implement `BincodeRead` for performance reasons.
///
/// If this returns an `Error`, `reader` may be in an invalid state.
#[inline(always)]
pub fn deserialize_from_custom_seed<
'a,
R: BincodeRead<'a>,
T: serde::de::DeserializeSeed<'a>,
>(
&self,
seed: T,
reader: R,
) -> Result<T::Value> {
config_map!(self, opts => ::internal::deserialize_from_custom_seed(seed, reader, opts))
}

/// Executes the acceptor with a serde::Deserializer instance.
/// NOT A PART OF THE STABLE PUBLIC API
#[doc(hidden)]
pub fn with_deserializer<'a, A, R>(&self, reader: R, acceptor: A) -> A::Output
where A: DeserializerAcceptor<'a>,
R: BincodeRead<'a>
pub fn with_deserializer<'a, A, R>(&self, reader: R, acceptor: A) -> A::Output
where
A: DeserializerAcceptor<'a>,
R: BincodeRead<'a>,
{
config_map!(self, opts => {
let mut deserializer = ::de::Deserializer::new(reader, opts);
Expand All @@ -301,8 +352,9 @@ impl Config {
/// NOT A PART OF THE STABLE PUBLIC API
#[doc(hidden)]
pub fn with_serializer<A, W>(&self, writer: W, acceptor: A) -> A::Output
where A: SerializerAcceptor,
W: Write
where
A: SerializerAcceptor,
W: Write,
{
config_map!(self, opts => {
let mut serializer = ::ser::Serializer::new(writer, opts);
Expand Down
Loading

0 comments on commit 36910f9

Please sign in to comment.