summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTreehugger Robot <treehugger-gerrit@google.com>2022-12-17 10:43:03 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-12-17 10:43:03 +0000
commite8ff8d0abf4b7bb771f0881af3219e9165e58b65 (patch)
tree164cb5fc6b1317a844aed21d13904f67f9fbe157
parent3a76fea27d0db9035a54c14d11a6ea08a32171bd (diff)
parent629dce79d2f66938170b93d27cc409325b8c1618 (diff)
downloadoctets-e8ff8d0abf4b7bb771f0881af3219e9165e58b65.tar.gz
Merge "Upgrade octets to 0.2.0" am: 954e4df889 am: 9232a5f665 am: 629dce79d2
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/octets/+/2345767 Change-Id: Ie2e264a870f782ba193e4aa6a0b45fa71b5ffc95 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
-rw-r--r--.cargo_vcs_info.json2
-rw-r--r--Android.bp6
-rw-r--r--Cargo.toml7
-rw-r--r--Cargo.toml.orig2
-rw-r--r--METADATA12
-rw-r--r--src/lib.rs22
6 files changed, 33 insertions, 18 deletions
diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json
index 7eb1d2d..9787b6f 100644
--- a/.cargo_vcs_info.json
+++ b/.cargo_vcs_info.json
@@ -1,6 +1,6 @@
{
"git": {
- "sha1": "1c612215d636616e8ea07f640f3829c7f1b39000"
+ "sha1": "4bda0917dd5aa535f39214063ee85c2cad00ceb2"
},
"path_in_vcs": "octets"
} \ No newline at end of file
diff --git a/Android.bp b/Android.bp
index 6315d5d..629b047 100644
--- a/Android.bp
+++ b/Android.bp
@@ -1,8 +1,6 @@
// This file is generated by cargo2android.py --config cargo2android.json.
// Do not modify this file as changes will be overridden on upgrade.
-
-
package {
default_applicable_licenses: ["external_rust_crates_octets_license"],
}
@@ -25,7 +23,7 @@ rust_library {
host_supported: true,
crate_name: "octets",
cargo_env_compat: true,
- cargo_pkg_version: "0.1.0",
+ cargo_pkg_version: "0.2.0",
srcs: ["src/lib.rs"],
edition: "2018",
apex_available: [
@@ -40,7 +38,7 @@ rust_test {
host_supported: true,
crate_name: "octets",
cargo_env_compat: true,
- cargo_pkg_version: "0.1.0",
+ cargo_pkg_version: "0.2.0",
srcs: ["src/lib.rs"],
test_suites: ["general-tests"],
auto_gen_config: true,
diff --git a/Cargo.toml b/Cargo.toml
index 0202601..680f1f4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,10 +12,13 @@
[package]
edition = "2018"
name = "octets"
-version = "0.1.0"
+version = "0.2.0"
authors = ["Alessandro Ghedini <alessandro@ghedini.me>"]
description = "Zero-copy abstraction for parsing and constructing network packets"
-keywords = ["quic", "http3"]
+keywords = [
+ "quic",
+ "http3",
+]
categories = ["network-programming"]
license = "BSD-2-Clause"
repository = "https://github.com/cloudflare/quiche"
diff --git a/Cargo.toml.orig b/Cargo.toml.orig
index 21f589f..ebddee4 100644
--- a/Cargo.toml.orig
+++ b/Cargo.toml.orig
@@ -1,6 +1,6 @@
[package]
name = "octets"
-version = "0.1.0"
+version = "0.2.0"
authors = ["Alessandro Ghedini <alessandro@ghedini.me>"]
edition = "2018"
description = "Zero-copy abstraction for parsing and constructing network packets"
diff --git a/METADATA b/METADATA
index 5b61482..e257b11 100644
--- a/METADATA
+++ b/METADATA
@@ -1,3 +1,7 @@
+# This project was upgraded with external_updater.
+# Usage: tools/external_updater/updater.sh update rust/crates/octets
+# For more info, check https://cs.android.com/android/platform/superproject/+/master:tools/external_updater/README.md
+
name: "octets"
description: "Zero-copy abstraction for parsing and constructing network packets"
third_party {
@@ -7,13 +11,13 @@ third_party {
}
url {
type: ARCHIVE
- value: "https://static.crates.io/crates/octets/octets-0.1.0.crate"
+ value: "https://static.crates.io/crates/octets/octets-0.2.0.crate"
}
- version: "0.1.0"
+ version: "0.2.0"
license_type: NOTICE
last_upgrade_date {
year: 2022
- month: 9
- day: 20
+ month: 12
+ day: 13
}
}
diff --git a/src/lib.rs b/src/lib.rs
index 67d40be..4f504bf 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -197,7 +197,7 @@ impl<'a> Octets<'a> {
/// Reads `len` bytes from the current offset without copying and advances
/// the buffer.
- pub fn get_bytes(&mut self, len: usize) -> Result<Octets> {
+ pub fn get_bytes(&mut self, len: usize) -> Result<Octets<'a>> {
if self.cap() < len {
return Err(BufferTooShortError);
}
@@ -214,7 +214,7 @@ impl<'a> Octets<'a> {
/// Reads `len` bytes from the current offset without copying and advances
/// the buffer, where `len` is an unsigned 8-bit integer prefix.
- pub fn get_bytes_with_u8_length(&mut self) -> Result<Octets> {
+ pub fn get_bytes_with_u8_length(&mut self) -> Result<Octets<'a>> {
let len = self.get_u8()?;
self.get_bytes(len as usize)
}
@@ -222,7 +222,7 @@ impl<'a> Octets<'a> {
/// Reads `len` bytes from the current offset without copying and advances
/// the buffer, where `len` is an unsigned 16-bit integer prefix in network
/// byte-order.
- pub fn get_bytes_with_u16_length(&mut self) -> Result<Octets> {
+ pub fn get_bytes_with_u16_length(&mut self) -> Result<Octets<'a>> {
let len = self.get_u16()?;
self.get_bytes(len as usize)
}
@@ -230,14 +230,14 @@ impl<'a> Octets<'a> {
/// Reads `len` bytes from the current offset without copying and advances
/// the buffer, where `len` is an unsigned variable-length integer prefix
/// in network byte-order.
- pub fn get_bytes_with_varint_length(&mut self) -> Result<Octets> {
+ pub fn get_bytes_with_varint_length(&mut self) -> Result<Octets<'a>> {
let len = self.get_varint()?;
self.get_bytes(len as usize)
}
/// Reads `len` bytes from the current offset without copying and without
/// advancing the buffer.
- pub fn peek_bytes(&self, len: usize) -> Result<Octets> {
+ pub fn peek_bytes(&self, len: usize) -> Result<Octets<'a>> {
if self.cap() < len {
return Err(BufferTooShortError);
}
@@ -290,13 +290,18 @@ impl<'a> Octets<'a> {
self.buf.len()
}
+ /// Returns `true` if the buffer is empty.
+ pub fn is_empty(&self) -> bool {
+ self.buf.len() == 0
+ }
+
/// Returns the current offset of the buffer.
pub fn off(&self) -> usize {
self.off
}
/// Returns a reference to the internal buffer.
- pub fn buf(&self) -> &[u8] {
+ pub fn buf(&self) -> &'a [u8] {
self.buf
}
@@ -626,6 +631,11 @@ impl<'a> OctetsMut<'a> {
self.buf.len()
}
+ /// Returns `true` if the buffer is empty.
+ pub fn is_empty(&self) -> bool {
+ self.buf.len() == 0
+ }
+
/// Returns the current offset of the buffer.
pub fn off(&self) -> usize {
self.off