You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: stream.rs
    path of file: ./repos/pdf/pdf/src/object
    
    the code of the file until where you have to start completion: use datasize::DataSize;

use crate as pdf;
use crate::object::*;
use crate::primitive::*;
use crate::error::*;
use crate::parser::Lexer;
use crate::enc::{StreamFilter, decode};

use std::ops::{Deref, Range};
use std::fmt;

#[derive(Clone)]
pub (crate) enum StreamData {
    Generated(Arc<[u8]>),
    Original(Range<usize>, PlainRef),
}
datasize::non_dynamic_const_heap_size!(StreamData, std::mem::size_of::<StreamData>());

/// Simple Stream object with only some additional entries from the stream dict (I).
#[derive(Clone, DataSize)]
pub struct Stream<I> {
    pub info: StreamInfo<I>,
    pub (crate) inner_data: StreamData,
}
impl<I: Object> Stream<I> {
    pub fn from_stream(s: PdfStream, resolve: &impl Resolve) -> Result<Self> {
        let PdfStream {info, inner} = s;
        let info = StreamInfo::<I>::from_primitive(Primitive::Dictionary (info), resolve)?;
        let inner_data = match inner {
            StreamInner::InFile { id, file_range } => StreamData::Original(file_range, id),
            StreamInner::Pending { data } => StreamData::Generated(data)
        };
        Ok(Stream { info, inner_data })
    }

    /// the data is not compressed. the specified filters are to be applied when compressing the data
    pub fn new_with_filters(i: I, data: impl Into<Arc<[u8]>>, filters: Vec<StreamFilter>) -> Stream<I> {
        Stream {
            info: StreamInfo {
                filters,
                file: None,
                file_filters: Vec::new(),
                info: i
            },
            inner_data: StreamData::Generated(data.into()),
        }
    }
    pub fn new(i: I, data: impl Into<Arc<[u8]>>) -> Stream<I> {
        Stream {
            info: StreamInfo {
                filters: Vec::new(),
                file: None,
                file_filters: Vec::new()
    
    fn from_primitive(p: Primitive, resolve: &impl Resolve) -> Result<Self> {
        let mut dict = Dictionary::from_primitive(p, resolve)?;

        let _length = usize::from_primitive(
            dict.remove("Length").ok_or(PdfError::MissingEntry{ typ: "StreamInfo", field: "Length".into() })?,
            resolve)?;

        let filters = Vec::<Name>::from_primitive(
            dict.remove("Filter").unwrap_or(Primitive::Null),
            resolve)?;

        let decode_params = Vec::<Option<Dictionary>>::from_primitive(
            dict.remove("DecodeParms").unwrap_or(Primitive::Null),
            resolve)?;

        let file = Option::<FileSpec>::from_primitive(
            dict.remove("F").unwrap_or(Primitive::Null),
            resolve)?;

        let file_filters = Vec::<Name>::from_primitive(
            dict.remove("FFilter").unwrap_or(Primitive::Null),
            resolve)?;

        let file_decode_params = Vec::<Dictionary>::from_primitive(
            dict.remove("FDecodeParms").unwrap_or(Primitive::Null),
            resolve)?;


        let mut new_filters = Vec::new();
        let mut new_file_filters = Vec::new();

        for (i, filter) in filters.iter().enumerate() {
            let params = match decode_params.get(i) {
                Some(Some(params)) => params.clone(),
                _ => Dictionary::default(),
            };
            new_filters.push(StreamFilter::from_kind_and_params(filter, params, resolve)?);
        }
        for (i, filter) in file_filters.iter().enumerate() {
            let params = match file_decode_params.get(i) {
                Some(params) => params.clone(),
                None => Dictionary::default(),
            };
            new_file_filters.push(StreamFilter::from_kind_and_params(filter, params, resolve)?);
        }

        Ok(StreamInfo {
            // General
            filters: new_filters,
            file,
            file_filters: new_file_filters,
            // Special
            info: T::from_primitive(Primitive::Dictionary (dict), resolve)?,
        })
    }