pub fn open(name: &str) -> Result<Table> {
    let mut oo = OpenOptions::new();
    oo
      .read(true)
      .write(true)
      .create(true);

    let idx = format!("{}.idx", name);
    let p = Path::new(&idx);

    let existed = p.exists();

    let header_file = RefCell::new(oo.open(p).map_err(Error::Io)?);
    let data_file = RefCell::new(oo.open(format!("{}.dat", name)).map_err(Error::Io)?);

    let header = if existed {
      serde_msgpack::from_read(&*header_file.borrow()).map_err(Error::MsgPackDec)?
    } else {
      Vec::new()
    };
    let len = header.iter().sum();
    Ok(Table {
      header,
      header_file,
      data_file,
      len,
    })
  }
/// Open a table with a given name, creating it on the disk if it doesn't exist.
Open a table with a given name, creating it on the disk if it doesn't exist.
Open a table with a given name creating it on the disk if it doesn ' t exist .
pub fn open(name: &str) -> Result<Table> {
    let mut oo = OpenOptions::new();
    oo
      .read(true)
      .write(true)
      .create(true);
    let idx = format!("{}.idx", name);
    let p = Path::new(&idx);
    let existed = p.exists();
    let header_file = RefCell::new(oo.open(p).map_err(Error::Io)?);
    let data_file = RefCell::new(oo.open(format!("{}.dat", name)).map_err(Error::Io)?);
    let header = if existed {
      serde_msgpack::from_read(&*header_file.borrow()).map_err(Error::MsgPackDec)?
    } else {
      Vec::new()
    };
    let len = header.iter().sum();
    Ok(Table {
      header,
      header_file,
      data_file,
      len,
    })
  }
pub fn open ( name : & str ) -> Result < Table > { let mut oo = OpenOptions :: new ( ) ; oo . read ( true ) . write ( true ) . create ( true ) ; let idx = format ! ( " " name ) ; let p = Path :: new ( & idx ) ; let existed = p . exists ( ) ; let header_file = RefCell :: new ( oo . open ( p ) . map_err ( Error :: Io ) ? ) ; let data_file = RefCell :: new ( oo . open ( format ! ( " " name ) ) . map_err ( Error :: Io ) ? ) ; let header = if existed { serde_msgpack :: from_read ( & * header_file . borrow ( ) ) . map_err ( Error :: MsgPackDec ) ? } else { Vec :: new ( ) } ; let len = header . iter ( ) . sum ( ) ; Ok ( Table { header , header_file , data_file , len , } ) }
Open a table with a given name, creating it on the disk if it doesn't exist.
Open a table with a given name creating it on the disk if it doesn ' t exist .
name
&str