Struct stringsext::finding_collection::FindingCollection[][src]

pub struct FindingCollection<'a> {
    pub v: Vec<Finding<'a>>,
    pub first_byte_position: u64,
    output_buffer_bytes: Box<[u8]>,
    pub str_buf_overflow: bool,
    _marker: PhantomPinned,
}
Expand description

FindingCollection is a set of ordered Finding s. The box output_buffer_bytes and the struct Finding are self-referential, because Finding.s points into output_buffer_bytes. Therefore, special care is taken that, output_buffer_bytes is protected from being moved in memory:

  1. output_buffer_bytes is private.
  2. The returned FindingCollection is wrapped in a Pin<Box<FindingCollection>>>.

Fields

v: Vec<Finding<'a>>

Finding s in this vector are in chronological order.

first_byte_position: u64

All concurrent ScannerState::scan() start at the same byte. All Finding.position refer to first_byte_position as zero.

output_buffer_bytes: Box<[u8]>

A buffer containing the UTF-8 representation of all findings during one Self::from() run. First, the Decoder fills in some UTF-8 string. This string is then filtered. The result of this filtering is a collection of Finding-objects stored in a FindingCollection. The Finding-objects have a &str-member called Finding.s that is a substring (slice) of output_buffer_bytes.

str_buf_overflow: bool

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 least one Finding got lost. This incident is reported to the user. If ever this happens, the OUTPUT_BUF_LEN was not chosen big enough.

_marker: PhantomPinned

Implementations

First, scans for valid encoded strings in input_buffer, then decodes them using ss.decoder to UTF-8 and writes the results as UTF-8 in fc.output_buffer_bytes. Finally some filter is applied to the found strings retaining only those who satisfy the filter criteria.

  • The input of this function is input_buffer.
  • The output of this function is the returned FindingCollection.

The input parameter input_file_id is forwarded and stored in each Finding of the returned FindingCollection.
The function keeps its inner state in ss.decoder, ss.last_scan_run_leftover, ss.last_run_str_was_printed_and_is_maybe_cut_str and ss.consumed_bytes.
ss.mission is not directly used in this function, but some part of it, the ss.mission.filter, is forwarded to the helper function: helper::SplitStr::next().
In case this is the last input_buffer of the stream, last must be set to correctly flush the ss.decoder.

Clears the buffer to make more space after buffer overflow. Tag the collection as overflowed.

This method formats and dumps a FindingCollection to the output channel, usually stdout.

Methods from Deref<Target = Vec<Finding<'a>>>

Returns the number of elements the vector can hold without reallocating.

Examples

let vec: Vec<i32> = Vec::with_capacity(10);
assert_eq!(vec.capacity(), 10);

Extracts a slice containing the entire vector.

Equivalent to &s[..].

Examples

use std::io::{self, Write};
let buffer = vec![1, 2, 3, 5, 8];
io::sink().write(buffer.as_slice()).unwrap();

Returns a raw pointer to the vector’s buffer.

The caller must ensure that the vector outlives the pointer this function returns, or else it will end up pointing to garbage. Modifying the vector may cause its buffer to be reallocated, which would also make any pointers to it invalid.

The caller must also ensure that the memory the pointer (non-transitively) points to is never written to (except inside an UnsafeCell) using this pointer or any pointer derived from it. If you need to mutate the contents of the slice, use as_mut_ptr.

Examples

let x = vec![1, 2, 4];
let x_ptr = x.as_ptr();

unsafe {
    for i in 0..x.len() {
        assert_eq!(*x_ptr.add(i), 1 << i);
    }
}
🔬 This is a nightly-only experimental API. (allocator_api)

Returns a reference to the underlying allocator.

Returns the number of elements in the vector, also referred to as its ‘length’.

Examples

let a = vec![1, 2, 3];
assert_eq!(a.len(), 3);

Returns true if the vector contains no elements.

Examples

let mut v = Vec::new();
assert!(v.is_empty());

v.push(1);
assert!(!v.is_empty());

Trait Implementations

Formats the value using the given formatter. Read more

We consider the “content” of a FindingCollection to be FindingCollection::v which is a Vec<Finding>.

The resulting type after dereferencing.

Dereferences the value.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Performs the conversion.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.