Skip to content

Commit 9c9bf16

Browse files
committed
0.3.4
1 parent 0e48acd commit 9c9bf16

File tree

6 files changed

+18
-17
lines changed

6 files changed

+18
-17
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "fitsrs"
3-
version = "0.3.3"
3+
version = "0.3.4"
44
authors = ["Matthieu Baumann <[email protected]>"]
55
edition = "2018"
66
description = "Implementation of the FITS image parser"

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ while let Some(Ok(hdu)) = hdu_list.next() {
166166
.get_num_bytes_data_block();
167167

168168
let data = hdu_list.get_data(&hdu)
169+
.bytes()
169170
.collect::<Vec<_>>();
170171

171172
assert_eq!(num_bytes as usize, data.len());

src/async_fits.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ where
131131
let hdu = if !self.start {
132132
// We must consume the bytes until the next header is found
133133
// if eof then the iterator finishes
134-
let mut consume_tokens_until_next_hdu = self.consume_until_next_hdu();
134+
let consume_tokens_until_next_hdu = self.consume_until_next_hdu();
135135
let eof = match std::pin::pin!(consume_tokens_until_next_hdu).poll(cx) {
136136
Poll::Pending => return Poll::Pending,
137137
// The future finished returning the eof information
@@ -143,7 +143,7 @@ where
143143
if !eof {
144144
// parse the extension HDU
145145
let r = &mut self.reader;
146-
let mut parse_x_hdu = hdu::AsyncHDU::new_xtension(r);
146+
let parse_x_hdu = hdu::AsyncHDU::new_xtension(r);
147147
match std::pin::pin!(parse_x_hdu).poll(cx) {
148148
Poll::Pending => return Poll::Pending,
149149
// the future finished, returning the parsed hdu or the error while parsing it
@@ -157,7 +157,7 @@ where
157157
}
158158
} else {
159159
// parse the primary HDU
160-
let mut parse_first_hdu = hdu::AsyncHDU::new_primary(&mut self.reader);
160+
let parse_first_hdu = hdu::AsyncHDU::new_primary(&mut self.reader);
161161
match std::pin::pin!(parse_first_hdu).poll(cx) {
162162
Poll::Pending => return Poll::Pending,
163163
// the future finished, returning the parsed hdu or the error while parsing it

src/hdu/data/asciitable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use async_trait::async_trait;
22
use futures::AsyncReadExt;
3-
use std::fmt::Debug;
43
use std::io::Read;
4+
use std::{fmt::Debug, io::BufReader};
55

66
use super::{stream::St, AsyncDataBufRead};
77

@@ -10,17 +10,17 @@ use crate::hdu::header::extension::asciitable::AsciiTable;
1010
use crate::hdu::header::extension::Xtension;
1111
use crate::hdu::header::Header;
1212

13-
use std::io::{Bytes, Take};
13+
use std::io::Take;
1414
impl<'a, R> FitsRead<'a, AsciiTable> for R
1515
where
1616
R: Read + Debug + 'a,
1717
{
18-
type Data = Bytes<Take<&'a mut R>>;
18+
type Data = BufReader<Take<&'a mut R>>;
1919

2020
fn read_data_unit(&'a mut self, header: &Header<AsciiTable>, _start_pos: u64) -> Self::Data {
2121
let limit = header.get_xtension().get_num_bytes_data_block();
2222

23-
self.take(limit).bytes()
23+
BufReader::new(self.take(limit))
2424
}
2525
}
2626

src/hdu/data/bintable/data.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::hdu::header::extension::bintable::{BinTable, TFormType};
1010
use crate::hdu::FitsRead;
1111
use byteorder::BigEndian;
1212
use log::warn;
13-
use std::io::Read;
14-
use std::io::{Bytes, SeekFrom};
13+
use std::io::SeekFrom;
14+
use std::io::{BufReader, Read};
1515

1616
impl<'a, R> FitsRead<'a, BinTable> for R
1717
where
@@ -173,9 +173,9 @@ where
173173
R: Read,
174174
{
175175
/// Gives an iterator over the bytes of the main data table
176-
pub fn bytes(self) -> Bytes<Take<R>> {
176+
pub fn bytes(self) -> BufReader<Take<R>> {
177177
let only_main_data_table = self.reader.take(self.main_data_table_byte_size as u64);
178-
only_main_data_table.bytes()
178+
BufReader::new(only_main_data_table)
179179
}
180180
}
181181

src/lib.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ mod tests {
8585

8686
#[test]
8787
fn test_fits_image_mandatory_kw() {
88-
let f = File::open("samples/hipsgen/Npix208.fits").unwrap();
88+
let f = BufReader::new(File::open("samples/hipsgen/Npix208.fits").unwrap());
8989
let bytes: Result<Vec<_>, _> = f.bytes().collect();
9090
let buf = bytes.unwrap();
9191

@@ -157,7 +157,7 @@ mod tests {
157157

158158
#[test]
159159
fn test_fits_image_f32() {
160-
let f = File::open("samples/hipsgen/Npix208.fits").unwrap();
160+
let f = BufReader::new(File::open("samples/hipsgen/Npix208.fits").unwrap());
161161
let bytes: Result<Vec<_>, _> = f.bytes().collect();
162162
let buf = bytes.unwrap();
163163

@@ -460,7 +460,7 @@ mod tests {
460460
let num_bytes = hdu.get_header().get_xtension().get_num_bytes_data_block();
461461
let bytes = hdu_list.get_data(&hdu);
462462

463-
assert_eq!(num_bytes as usize, bytes.collect::<Vec<_>>().len());
463+
assert_eq!(num_bytes as usize, bytes.bytes().collect::<Vec<_>>().len());
464464
}
465465
}
466466
}
@@ -524,7 +524,7 @@ mod tests {
524524
let num_bytes = hdu.get_header().get_xtension().get_num_bytes_data_block();
525525

526526
let it_bytes = hdu_list.get_data(&hdu);
527-
let data = it_bytes.collect::<Vec<_>>();
527+
let data = it_bytes.bytes().collect::<Vec<_>>();
528528
assert_eq!(num_bytes as usize, data.len());
529529
}
530530
_ => (),
@@ -687,7 +687,7 @@ mod tests {
687687
HDU::XASCIITable(hdu) => {
688688
let num_bytes = hdu.get_header().get_xtension().get_num_bytes_data_block();
689689

690-
let data = hdu_list.get_data(&hdu).collect::<Vec<_>>();
690+
let data = hdu_list.get_data(&hdu).bytes().collect::<Vec<_>>();
691691

692692
assert_eq!(num_bytes as usize, data.len());
693693
}

0 commit comments

Comments
 (0)