mirror of https://github.com/encounter/nod-rs.git
Remove unstable library features
This commit is contained in:
parent
20bed46d43
commit
e7fc234fdf
|
@ -9,6 +9,7 @@ jobs:
|
|||
matrix:
|
||||
platform: [ ubuntu-latest, macos-latest, windows-latest ]
|
||||
toolchain: [ stable, 1.35.0, nightly ]
|
||||
fail-fast: false
|
||||
runs-on: ${{ matrix.platform }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
@ -22,7 +23,7 @@ jobs:
|
|||
args: --release --all-features
|
||||
- uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: ${{ matrix.platform }}
|
||||
name: ${{ matrix.platform }}-${{ matrix.toolchain }}
|
||||
path: |
|
||||
target/release/nodtool
|
||||
target/release/nodtool.exe
|
||||
|
|
|
@ -1,5 +1,3 @@
|
|||
#![feature(with_options)]
|
||||
|
||||
use std::{env, fs, io};
|
||||
use std::io::BufWriter;
|
||||
use std::path::{Path, PathBuf};
|
||||
|
@ -8,10 +6,10 @@ use std::time::Instant;
|
|||
use clap::{AppSettings, clap_app};
|
||||
use file_size;
|
||||
|
||||
use nod::Result;
|
||||
use nod::disc::{new_disc_base, PartReadStream};
|
||||
use nod::fst::NodeType;
|
||||
use nod::io::{has_extension, new_disc_io};
|
||||
use nod::Result;
|
||||
|
||||
fn main() -> Result<()> {
|
||||
let matches = clap_app!(nodtool =>
|
||||
|
|
|
@ -75,7 +75,7 @@ impl<'a> Seek for GCPartReadStream<'a> {
|
|||
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
|
||||
self.offset = match pos {
|
||||
SeekFrom::Start(v) => v,
|
||||
SeekFrom::End(v) => (self.stream_len()? as i64 + v) as u64,
|
||||
SeekFrom::End(v) => (self.stable_stream_len()? as i64 + v) as u64,
|
||||
SeekFrom::Current(v) => (self.offset as i64 + v) as u64,
|
||||
};
|
||||
let block = self.offset / BUFFER_SIZE as u64;
|
||||
|
@ -86,16 +86,16 @@ impl<'a> Seek for GCPartReadStream<'a> {
|
|||
io::Result::Ok(self.offset)
|
||||
}
|
||||
|
||||
fn stream_len(&mut self) -> io::Result<u64> {
|
||||
self.stream.stream_len()
|
||||
}
|
||||
|
||||
fn stream_position(&mut self) -> io::Result<u64> {
|
||||
io::Result::Ok(self.offset)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ReadStream for GCPartReadStream<'a> {}
|
||||
impl<'a> ReadStream for GCPartReadStream<'a> {
|
||||
fn stable_stream_len(&mut self) -> io::Result<u64> {
|
||||
self.stream.stable_stream_len()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> PartReadStream for GCPartReadStream<'a> {
|
||||
fn begin_file_stream(&mut self, node: &Node) -> io::Result<SharedWindowedReadStream> {
|
||||
|
|
|
@ -361,7 +361,7 @@ impl<'a> Seek for WiiPartReadStream<'a> {
|
|||
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
|
||||
self.offset = match pos {
|
||||
SeekFrom::Start(v) => v,
|
||||
SeekFrom::End(v) => (self.stream_len()? as i64 + v) as u64,
|
||||
SeekFrom::End(v) => (self.stable_stream_len()? as i64 + v) as u64,
|
||||
SeekFrom::Current(v) => (self.offset as i64 + v) as u64,
|
||||
};
|
||||
let block = self.offset / BLOCK_SIZE as u64;
|
||||
|
@ -372,16 +372,16 @@ impl<'a> Seek for WiiPartReadStream<'a> {
|
|||
io::Result::Ok(self.offset)
|
||||
}
|
||||
|
||||
fn stream_len(&mut self) -> io::Result<u64> {
|
||||
io::Result::Ok(to_block_size(self.stream.stream_len()?))
|
||||
}
|
||||
|
||||
fn stream_position(&mut self) -> io::Result<u64> {
|
||||
io::Result::Ok(self.offset)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ReadStream for WiiPartReadStream<'a> {}
|
||||
impl<'a> ReadStream for WiiPartReadStream<'a> {
|
||||
fn stable_stream_len(&mut self) -> io::Result<u64> {
|
||||
io::Result::Ok(to_block_size(self.stream.stable_stream_len()?))
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq, BinRead)]
|
||||
pub(crate) struct WiiPartition {
|
||||
|
|
|
@ -211,7 +211,7 @@ impl<'a> Seek for NFSReadStream<'a> {
|
|||
fn seek(&mut self, pos: SeekFrom) -> io::Result<u64> {
|
||||
self.offset = match pos {
|
||||
SeekFrom::Start(v) => v,
|
||||
SeekFrom::End(v) => (self.stream_len()? as i64 + v) as u64,
|
||||
SeekFrom::End(v) => (self.stable_stream_len()? as i64 + v) as u64,
|
||||
SeekFrom::Current(v) => (self.offset as i64 + v) as u64,
|
||||
};
|
||||
self.set_logical_addr(self.offset)
|
||||
|
@ -222,16 +222,16 @@ impl<'a> Seek for NFSReadStream<'a> {
|
|||
io::Result::Ok(self.offset)
|
||||
}
|
||||
|
||||
fn stream_len(&mut self) -> io::Result<u64> {
|
||||
todo!()
|
||||
}
|
||||
|
||||
fn stream_position(&mut self) -> io::Result<u64> {
|
||||
io::Result::Ok(self.offset)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ReadStream for NFSReadStream<'a> {}
|
||||
impl<'a> ReadStream for NFSReadStream<'a> {
|
||||
fn stable_stream_len(&mut self) -> io::Result<u64> {
|
||||
todo!()
|
||||
}
|
||||
}
|
||||
|
||||
impl DiscIO for DiscIONFS {
|
||||
fn begin_read_stream(&self, offset: u64) -> io::Result<Box<dyn ReadStream + '_>> {
|
||||
|
|
|
@ -26,8 +26,6 @@
|
|||
//! println!(s);
|
||||
//! }
|
||||
//! ```
|
||||
#![feature(seek_stream_len)]
|
||||
|
||||
pub mod fst;
|
||||
pub mod disc;
|
||||
pub mod io;
|
||||
|
|
|
@ -15,9 +15,22 @@ macro_rules! array_ref {
|
|||
}}
|
||||
}
|
||||
|
||||
pub trait ReadStream: Read + Seek {}
|
||||
pub trait ReadStream: Read + Seek {
|
||||
/// Replace with [`Read.stream_len`] when stabilized.
|
||||
///
|
||||
/// <https://github.com/rust-lang/rust/issues/59359>
|
||||
fn stable_stream_len(&mut self) -> io::Result<u64>;
|
||||
}
|
||||
|
||||
impl ReadStream for File {}
|
||||
impl ReadStream for File {
|
||||
fn stable_stream_len(&mut self) -> io::Result<u64> {
|
||||
let before = self.stream_position()?;
|
||||
let result = self.seek(SeekFrom::End(0));
|
||||
// Try to restore position even if the above failed
|
||||
self.seek(SeekFrom::Start(before))?;
|
||||
result
|
||||
}
|
||||
}
|
||||
|
||||
trait WindowedReadStream: ReadStream {
|
||||
fn base_stream(&mut self) -> &mut dyn ReadStream;
|
||||
|
@ -39,7 +52,7 @@ pub struct SharedWindowedReadStream<'a> {
|
|||
#[inline(always)]
|
||||
fn windowed_read(stream: &mut dyn WindowedReadStream, buf: &mut [u8]) -> io::Result<usize> {
|
||||
let pos = stream.stream_position()?;
|
||||
let size = stream.stream_len()?;
|
||||
let size = stream.stable_stream_len()?;
|
||||
stream.base_stream().read(if pos + buf.len() as u64 > size {
|
||||
&mut buf[..(size - pos) as usize]
|
||||
} else {
|
||||
|
@ -73,16 +86,16 @@ impl<'a> Seek for OwningWindowedReadStream<'a> {
|
|||
windowed_seek(self, pos)
|
||||
}
|
||||
|
||||
fn stream_len(&mut self) -> io::Result<u64> {
|
||||
Result::Ok(self.end - self.begin)
|
||||
}
|
||||
|
||||
fn stream_position(&mut self) -> io::Result<u64> {
|
||||
Result::Ok(self.base.stream_position()? - self.begin)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ReadStream for OwningWindowedReadStream<'a> {}
|
||||
impl<'a> ReadStream for OwningWindowedReadStream<'a> {
|
||||
fn stable_stream_len(&mut self) -> io::Result<u64> {
|
||||
Result::Ok(self.end - self.begin)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> WindowedReadStream for OwningWindowedReadStream<'a> {
|
||||
fn base_stream(&mut self) -> &mut dyn ReadStream {
|
||||
|
@ -105,16 +118,16 @@ impl<'a> Seek for SharedWindowedReadStream<'a> {
|
|||
windowed_seek(self, pos)
|
||||
}
|
||||
|
||||
fn stream_len(&mut self) -> io::Result<u64> {
|
||||
Result::Ok(self.end - self.begin)
|
||||
}
|
||||
|
||||
fn stream_position(&mut self) -> io::Result<u64> {
|
||||
Result::Ok(self.base.stream_position()? - self.begin)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> ReadStream for SharedWindowedReadStream<'a> {}
|
||||
impl<'a> ReadStream for SharedWindowedReadStream<'a> {
|
||||
fn stable_stream_len(&mut self) -> io::Result<u64> {
|
||||
Result::Ok(self.end - self.begin)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> WindowedReadStream for SharedWindowedReadStream<'a> {
|
||||
fn base_stream(&mut self) -> &mut dyn ReadStream {
|
||||
|
|
Loading…
Reference in New Issue