diff --git a/.drone.yml b/.drone.yml new file mode 100644 index 0000000..68e9986 --- /dev/null +++ b/.drone.yml @@ -0,0 +1,52 @@ +--- +kind: pipeline +type: docker +name: common-utils-amd64 +platform: + arch: amd64 + os: linux + +steps: + - name: build-common-utils-amd64 + image: 084037375216.dkr.ecr.us-east-2.amazonaws.com/honda-builder + pull: always + environment: + PATH: /bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/.cargo/bin + CODECOV_TOKEN: + from_secret: codecov_token + commands: + - cargo build + - CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='coverage/cargo-test-%p-%m.profraw' cargo test + - mkdir -p target/coverage + - grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov + - codecov -B ${DRONE_BRANCH} -b ${DRONE_BUILD_NUMBER} -f target/coverage/tests.lcov -F amd64 +trigger: + event: + - custom + - push +--- +kind: pipeline +type: docker +name: common-utils-arm64 +platform: + arch: arm64 + os: linux + +steps: + - name: build-common-utils-arm64 + image: 084037375216.dkr.ecr.us-east-2.amazonaws.com/honda-builder + pull: always + environment: + PATH: /bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin:/root/.cargo/bin + CODECOV_TOKEN: + from_secret: codecov_token + commands: + - cargo build + - CARGO_INCREMENTAL=0 RUSTFLAGS='-Cinstrument-coverage' LLVM_PROFILE_FILE='coverage/cargo-test-%p-%m.profraw' cargo test + - mkdir -p target/coverage + - grcov . --binary-path ./target/debug/deps/ -s . -t lcov --branch --ignore-not-existing --ignore '../*' --ignore "/*" -o target/coverage/tests.lcov + - codecov -B ${DRONE_BRANCH} -b ${DRONE_BUILD_NUMBER} -f target/coverage/tests.lcov -F arm64 +trigger: + event: + - custom + - push diff --git a/src/buf.rs b/src/buf.rs index 31c092b..7287215 100644 --- a/src/buf.rs +++ b/src/buf.rs @@ -47,6 +47,11 @@ impl Buf { Self(NonNull::new_unchecked(b)) } } + pub fn create_from(buffer: &[u8]) -> Buf { + let mut buf = Self::new((buffer.len() + 7)/8*8); + let _ = buf.append(buffer); + buf + } #[inline(always)] pub fn iter(&self) -> impl Iterator { @@ -370,6 +375,11 @@ impl Pool { } } } + pub fn create_from(&self, buffer: &[u8]) -> Buf { + let mut buf = self.get_with_min_capacity(buffer.len()); + let _ = buf.append(buffer); + buf + } /// Get a buffer from the pool or direct allocation if min_capacity is larger than pool buffer capacity. #[inline]