Skip to content

Commit

Permalink
Move io into module
Browse files Browse the repository at this point in the history
  • Loading branch information
bbqsrc committed Feb 13, 2021
1 parent f7611ec commit 3c950bc
Show file tree
Hide file tree
Showing 11 changed files with 46 additions and 44 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --tests --features nightly
args: --tests --no-default-features --features nightly
- name: Run tests (std)
uses: actions-rs/cargo@v1
with:
command: test
args: --tests --features std-nightly
args: --tests --no-default-features --features std,nightly
- name: Run tests (alloc)
uses: actions-rs/cargo@v1
with:
command: test
args: --tests --features nightly,alloc
args: --tests --no-default-features --features alloc,nightly
test-stable:
runs-on: ${{ matrix.os }}
strategy:
Expand All @@ -49,13 +49,14 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: test
args: --no-default-features
- name: Run tests (std)
uses: actions-rs/cargo@v1
with:
command: test
args: --features std
args: --no-default-features --features std
- name: Run tests (alloc)
uses: actions-rs/cargo@v1
with:
command: test
args: --features alloc
args: --no-default-features --features alloc
11 changes: 5 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
[package]
name = "bare-io"
version = "0.2.1"
name = "core2"
version = "0.1.0"
authors = ["Brendan Molloy <brendan@bbqsrc.net>"]
description = "The bare essentials of std::io for use in no_std. Alloc support is optional."
license = "Apache-2.0 OR MIT"
edition = "2018"
repository = "https://github.com/bbqsrc/bare-io"
repository = "https://github.com/bbqsrc/core2"
categories = ["no-std"]

[dependencies]
memchr = { version = "2", default-features = false }

[features]
default = []
alloc = []
default = ["std"]
std = ["alloc"]
alloc = []
nightly = []
std-nightly = ["std", "nightly"]

[package.metadata.docs.rs]
features = ["nightly"]
2 changes: 1 addition & 1 deletion src/buffered.rs → src/io/buffered.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Buffering wrappers for I/O traits

use crate::{BufRead, Error, ErrorKind, Read, Result, Seek, SeekFrom, Write};
use crate::io::{BufRead, Error, ErrorKind, Read, Result, Seek, SeekFrom, Write};
use core::{cmp, fmt};

/// The `BufReader<R, S>` struct adds buffering to any reader.
Expand Down
2 changes: 1 addition & 1 deletion src/cursor.rs → src/io/cursor.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::{BufRead, Error, ErrorKind, Read, Result, Seek, SeekFrom, Write};
use super::{BufRead, Error, ErrorKind, Read, Result, Seek, SeekFrom, Write};
use core::cmp;

/// A `Cursor` wraps an in-memory buffer and provides it with a
Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions src/impls.rs → src/io/impls.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::error::{Error, ErrorKind, Result};
use crate::traits::{BufRead, Read, Seek, SeekFrom, Write};
use super::error::{Error, ErrorKind, Result};
use super::traits::{BufRead, Read, Seek, SeekFrom, Write};
use core::{cmp, fmt, mem};

// =============================================================================
Expand Down
26 changes: 26 additions & 0 deletions src/io/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#[cfg(feature = "nightly")]
mod buffered;
mod cursor;
mod error;
mod impls;
mod traits;
mod util;

#[cfg(not(feature = "std"))]
pub use cursor::Cursor;
#[cfg(not(feature = "std"))]
pub use error::{Error, ErrorKind, Result};
#[cfg(not(feature = "std"))]
pub use traits::{BufRead, Bytes, Chain, Read, Seek, SeekFrom, Take, Write};

#[cfg(feature = "std")]
pub use std::io::{
BufRead, Bytes, Chain, Cursor, Error, ErrorKind, Read, Result, Seek, SeekFrom, Take, Write,
};

// Use this crate's implementation on both std and no_std
#[cfg(feature = "nightly")]
pub use buffered::{BufReader, BufWriter, LineWriter};

#[cfg(feature = "nightly")]
pub use util::copy;
File renamed without changes.
4 changes: 2 additions & 2 deletions src/util.rs → src/io/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
use core::mem::MaybeUninit;

#[cfg(feature = "nightly")]
use crate::{ErrorKind, Read, Write};
use crate::io::{ErrorKind, Read, Write};

#[cfg(feature = "nightly")]
pub fn copy<R: ?Sized, W: ?Sized, const S: usize>(
reader: &mut R,
writer: &mut W,
) -> crate::Result<u64>
) -> crate::io::Result<u64>
where
R: Read,
W: Write,
Expand Down
28 changes: 2 additions & 26 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,9 @@
#![cfg_attr(feature = "nightly", feature(maybe_uninit_ref))]
#![cfg_attr(all(feature = "std", feature = "nightly"), feature(read_initializer))]
#![cfg_attr(not(feature = "std"), no_std)]
#![cfg_attr(feature = "std", allow(dead_code))]

#[cfg(feature = "nightly")]
mod buffered;
mod cursor;
mod error;
mod impls;
mod traits;
mod util;
pub mod io;

#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(not(feature = "std"))]
pub use cursor::Cursor;
#[cfg(not(feature = "std"))]
pub use error::{Error, ErrorKind, Result};
#[cfg(not(feature = "std"))]
pub use traits::{BufRead, Bytes, Chain, Read, Seek, SeekFrom, Take, Write};

#[cfg(feature = "std")]
pub use std::io::{
BufRead, Bytes, Chain, Cursor, Error, ErrorKind, Read, Result, Seek, SeekFrom, Take, Write,
};

// Use this crate's implementation on both std and no_std
#[cfg(feature = "nightly")]
pub use buffered::{BufReader, BufWriter, LineWriter};

#[cfg(feature = "nightly")]
pub use util::copy;
2 changes: 1 addition & 1 deletion tests/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use bare_io::{self as io, BufRead, Cursor, Read, Write};
use core2::io::{self as io, BufRead, Cursor, Read, Write};
use core::cmp;

// #[test]
Expand Down

0 comments on commit 3c950bc

Please sign in to comment.