Skip to content

Commit

Permalink
pin self referential struct
Browse files Browse the repository at this point in the history
  • Loading branch information
Jens Getreu committed Sep 19, 2020
1 parent 411fe35 commit 0864ce0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ edition = "2018"
readme = "README.md"
description = "find multi-byte-encoded strings in binary data"
license = "MIT/Apache-2.0"
categories = ["command-line-utilities", "encoding", "text-processing",
categories = ["command-line-utilities", "encoding", "text-processing",
"filesystem"]
documentation = "https://blog.getreu.net/projects/stringsext/stringsext--manpage.html"
homepage = "https://blog.getreu.net/projects/stringsext/"
Expand All @@ -24,8 +24,9 @@ scoped_threadpool = "0.1.9"
anyhow = "1.0.27"
clap = "2.33.0"
structopt = "0.3.12"
pin-project = "0.4.23"

# Metadata for debian packages with cargo-deb
# Metadata for Debian packages with cargo-deb

[package.metadata.deb]
maintainer = "Jens Getreu, <[email protected]>"
Expand Down
5 changes: 5 additions & 0 deletions src/finding.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ use crate::mission::Mission;
use crate::options::Radix;
use crate::options::ARGS;
use crate::options::ASCII_ENC_LABEL;
use pin_project::pin_project;
use std::io::Write;
use std::ops::Deref;
use std::str;
Expand All @@ -31,6 +32,9 @@ pub const OUTPUT_BUF_LEN: usize = 0x40;
pub const OUTPUT_LINE_METADATA_LEN: usize = 40;

/// `FindingCollection` is a set of ordered `Finding` s.
/// This struct is self referential, because `Finding` points into
/// `output_buffer_bytes`, hence pinning is required here.
#[pin_project]
#[derive(Debug)]
pub struct FindingCollection<'a> {
/// `Finding` s in this vector are in chronological order.
Expand All @@ -44,6 +48,7 @@ pub struct FindingCollection<'a> {
/// some `Finding`-objects stored in a `FindingCollection`. The
/// `Finding`-objects have a `&str`-member called `Finding::s` that is
/// a substring of `output_buffer_bytes`.
#[pin]
pub output_buffer_bytes: Box<[u8]>,
/// If `output_buffer` is too small to receive all findings, this is set
/// `true` indicating that only the last `Finding` s could be stored. At
Expand Down

0 comments on commit 0864ce0

Please sign in to comment.