about summary refs log tree commit diff
path: root/src/libstd
AgeCommit message (Collapse)AuthorLines
2014-05-07std: Add I/O timeouts to networking objectsAlex Crichton-15/+419
These timeouts all follow the same pattern as established by the timeouts on acceptors. There are three methods: set_timeout, set_read_timeout, and set_write_timeout. Each of these sets a point in the future after which operations will time out. Timeouts with cloned objects are a little trickier. Each object is viewed as having its own timeout, unaffected by other objects' timeouts. Additionally, timeouts do not propagate when a stream is cloned or when a cloned stream has its timeouts modified. This commit is just the public interface which will be exposed for timeouts, the implementation will come in later commits.
2014-05-07auto merge of #13964 : alexcrichton/rust/more-buffers, r=brsonbors-1/+63
This will allow methods like read_line() on RefReader, LimitReader, etc.
2014-05-07auto merge of #13751 : alexcrichton/rust/io-close-read, r=brsonbors-14/+205
Two new methods were added to TcpStream and UnixStream: fn close_read(&mut self) -> IoResult<()>; fn close_write(&mut self) -> IoResult<()>; These two methods map to shutdown()'s behavior (the system call on unix), closing the reading or writing half of a duplex stream. These methods are primarily added to allow waking up a pending read in another task. By closing the reading half of a connection, all pending readers will be woken up and will return with EndOfFile. The close_write() method was added for symmetry with close_read(), and I imagine that it will be quite useful at some point. Implementation-wise, librustuv got the short end of the stick this time. The native versions just delegate to the shutdown() syscall (easy). The uv versions can leverage uv_shutdown() for tcp/unix streams, but only for closing the writing half. Closing the reading half is done through some careful dancing to wake up a pending reader. As usual, windows likes to be different from unix. The windows implementation uses shutdown() for sockets, but shutdown() is not available for named pipes. Instead, CancelIoEx was used with same fancy synchronization to make sure everyone knows what's up. cc #11165
2014-05-07std: Add close_{read,write}() methods to I/OAlex Crichton-14/+205
Two new methods were added to TcpStream and UnixStream: fn close_read(&mut self) -> IoResult<()>; fn close_write(&mut self) -> IoResult<()>; These two methods map to shutdown()'s behavior (the system call on unix), closing the reading or writing half of a duplex stream. These methods are primarily added to allow waking up a pending read in another task. By closing the reading half of a connection, all pending readers will be woken up and will return with EndOfFile. The close_write() method was added for symmetry with close_read(), and I imagine that it will be quite useful at some point. Implementation-wise, librustuv got the short end of the stick this time. The native versions just delegate to the shutdown() syscall (easy). The uv versions can leverage uv_shutdown() for tcp/unix streams, but only for closing the writing half. Closing the reading half is done through some careful dancing to wake up a pending reader. As usual, windows likes to be different from unix. The windows implementation uses shutdown() for sockets, but shutdown() is not available for named pipes. Instead, CancelIoEx was used with same fancy synchronization to make sure everyone knows what's up. cc #11165
2014-05-07Test fixes and rebase conflictsAlex Crichton-51/+12
2014-05-07core: Move Option::expect to libstd from libcoreAlex Crichton-4/+172
See #14008 for more details
2014-05-07core: Inherit the cell moduleAlex Crichton-318/+3
2014-05-07core: Add unwrap()/unwrap_err() methods to ResultAlex Crichton-6/+327
These implementations must live in libstd right now because the fmt module has not been migrated yet. This will occur in a later PR. Just to be clear, there are new extension traits, but they are not necessary once the std::fmt module has migrated to libcore, which is a planned migration in the future.
2014-05-07core: Inherit the result moduleAlex Crichton-784/+21
The unwrap()/unwrap_err() methods are temporarily removed, and will be added back in the next commit.
2014-05-07core: Add a limited implementation of failureAlex Crichton-32/+12
This adds an small of failure to libcore, hamstrung by the fact that std::fmt hasn't been migrated yet. A few asserts were re-worked to not use std::fmt features, but these asserts can go back to their original form once std::fmt has migrated. The current failure implementation is to just have some symbols exposed by std::rt::unwind that are linked against by libcore. This is an explicit circular dependency, unfortunately. This will be officially supported in the future through compiler support with much nicer failure messages. Additionally, there are two depended-upon symbols today, but in the future there will only be one (once std::fmt has migrated).
2014-05-07std: Remove a glob to get std to compileAlex Crichton-1/+1
2014-05-07core: Inherit possible string functionalityAlex Crichton-1945/+122
This moves as much allocation as possible from teh std::str module into core::str. This includes essentially all non-allocating functionality, mostly iterators and slicing and such. This primarily splits the Str trait into only having the as_slice() method, adding a new StrAllocating trait to std::str which contains the relevant new allocation methods. This is a breaking change if any of the methods of "trait Str" were overriden. The old functionality can be restored by implementing both the Str and StrAllocating traits. [breaking-change]
2014-05-07core: Inherit necessary unicode functionalityAlex Crichton-4991/+1
The unicode module remains private, but the normalization iterators require an allocation, so some functionality needs to remain in libstd
2014-05-07core: Inherit non-allocating slice functionalityAlex Crichton-1554/+53
This commit adds a new trait, MutableVectorAllocating, which represents functions on vectors which can allocate. This is another extension trait to slices which should be removed once a lang item exists for the ~ allocation.
2014-05-07core: Inherit the specific numeric modulesAlex Crichton-1506/+77
This implements all traits inside of core::num for all the primitive types, removing all the functionality from libstd. The std modules reexport all of the necessary items from the core modules.
2014-05-07core: Inherit what's possible from the num moduleAlex Crichton-849/+15
This strips out all string-related functionality from the num module. The inherited functionality is all that will be implemented in libcore (for now). Primarily, libcore will not implement the Float trait or any string-related functionality. It may be possible to migrate string parsing functionality into libcore in the future, but for now it will remain in libstd. All functionality in core::num is reexported in std::num.
2014-05-07core: Inhert ~/@/& cmp traits, remove old modulesAlex Crichton-150/+1
This commit removes the std::{managed, reference} modules. The modules serve essentially no purpose, and the only free function removed was `managed::ptr_eq` which can be achieved by comparing references. [breaking-change]
2014-05-07core: Inherit the cmp moduleAlex Crichton-299/+12
This removes the TotalOrd and TotalEq implementation macros, they will be added later to the numeric modules (where the other comparison implementations live).
2014-05-07core: Inherit the iter moduleAlex Crichton-3091/+15
2014-05-07core: Inherit the option moduleAlex Crichton-883/+10
2014-05-07core: Inherit the bool moduleAlex Crichton-305/+36
2014-05-07core: Inherit the tuple moduleAlex Crichton-351/+31
2014-05-07core: Inherit the clone moduleAlex Crichton-172/+1
2014-05-07core: Inherit the unit moduleAlex Crichton-53/+6
2014-05-07core: Inherit the default moduleAlex Crichton-27/+1
2014-05-07core: Inherit the raw moduleAlex Crichton-115/+1
2014-05-07core: Inherit the any moduleAlex Crichton-324/+9
2014-05-07core: Inherit the finally moduleAlex Crichton-160/+2
2014-05-07core: Inherit the char moduleAlex Crichton-846/+1
2014-05-07core: Inherit the container moduleAlex Crichton-109/+1
2014-05-07core: Inherit the ty moduleAlex Crichton-73/+1
2014-05-07core: Inherit the ops moduleAlex Crichton-575/+1
2014-05-07core: Inherit the kinds moduleAlex Crichton-282/+2
2014-05-07core: Inherit the cast moduleAlex Crichton-150/+1
2014-05-07core: Inherit the ptr moduleAlex Crichton-773/+2
2014-05-07core: Inherit the mem moduleAlex Crichton-462/+1
2014-05-07core: Inherit the intrinsics moduleAlex Crichton-488/+18
2014-05-07std: Implement the Buffer trait for some wrappersAlex Crichton-1/+63
This will allow methods like read_line() on RefReader, LimitReader, etc.
2014-05-07auto merge of #13958 : pcwalton/rust/detilde, r=pcwaltonbors-291/+356
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. r? @brson or @alexcrichton or whoever
2014-05-07auto merge of #13914 : alexcrichton/rust/pile-o-rustdoc-fixes, r=brsonbors-8/+8
Lots of assorted things here and there, all the details are in the commits. Closes #11712
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-291/+356
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-06auto merge of #13754 : alexcrichton/rust/net-experimental, r=brsonbors-1/+70
The underlying I/O objects implement a good deal of various options here and there for tuning network sockets and how they perform. Most of this is a relic of "whatever libuv provides", but these options are genuinely useful. It is unclear at this time whether these options should be well supported or not, or whether they have correct names or not. For now, I believe it's better to expose the functionality than to not, but all new methods are added with an #[experimental] annotation.
2014-05-06auto merge of #13897 : aturon/rust/issue-6085, r=bjzbors-61/+87
The `std::bitflags::bitflags!` macro did not provide support for adding attributes to the generates structure, due to limitations in the parser for macros. This patch works around the parser limitations by requiring a `flags` keyword in the `bitflags!` invocations: bitflags!( #[deriving(Hash)] #[doc="Three flags"] flags Flags: u32 { FlagA = 0x00000001, FlagB = 0x00000010, FlagC = 0x00000100 } ) The intent of `std::bitflags` is to allow building type-safe wrappers around C-style flags APIs. But in addition to construction these flags from the Rust side, we need a way to convert them from the C side. This patch adds a `from_bits` function, which is unsafe since the bits in question may not represent a valid combination of flags. Finally, this patch changes `std::io::FilePermissions` from an exposed `u32` representation to a typesafe representation (that only allows valid flag combinations) using the `std::bitflags`. Closes #6085.
2014-05-05auto merge of #13934 : huonw/rust/transmute-mut, r=alexcrichtonbors-39/+64
Turning a `&T` into an `&mut T` is undefined behaviour, and needs to be done very very carefully. Providing a convenience function for exactly this task is a bad idea, just tempting people into doing the wrong thing. (The right thing is to use types like `Cell`, `RefCell` or `Unsafe`.) cc https://github.com/mozilla/rust/issues/13933
2014-05-05auto merge of #13912 : seanmonstar/rust/logrecord, r=alexcrichtonbors-0/+6
The logging macros now create a LogRecord, and pass that to the Logger. This will allow custom loggers to change the formatting, and possible filter on more properties of the log record. DefaultLogger's formatting was taken from Python's default formatting: `LEVEL:from: message` Also included: fmt::Arguments now implement Show, so they can be used to extend format strings. @alexcrichton r?
2014-05-05Change std::io::FilePermission to a typesafe representationAaron Turon-36/+41
This patch changes `std::io::FilePermissions` from an exposed `u32` representation to a typesafe representation (that only allows valid flag combinations) using the `std::bitflags`, thus ensuring a greater degree of safety on the Rust side. Despite the change to the type, most code should continue to work as-is, sincde the new type provides bit operations in the style of C flags. To get at the underlying integer representation, use the `bits` method; to (unsafely) convert to `FilePermissions`, use `FilePermissions::from_bits`. Closes #6085. [breaking-change]
2014-05-05Add (unsafe) coercion from bits to std::bitflagsAaron Turon-0/+6
The intent of `std::bitflags` is to allow building type-safe wrappers around C-style flags APIs. But in addition to construction these flags from the Rust side, we need a way to convert them from the C side. This patch adds a `from_bits` function, which is unsafe since the bits in question may not represent a valid combination of flags.
2014-05-05Allow attributes in std::bitflags::bitflags!Aaron Turon-25/+40
The `std::bitflags::bitflags!` macro did not provide support for adding attributes to the generated structure or flags, due to limitations in the parser for macros. This patch works around the parser limitations by requiring a `flags` keyword in the overall `bitflags!` invocation, and a `static` keyword for each flag: bitflags!( #[deriving(Hash)] #[doc="Three flags"] flags Flags: u32 { #[doc="The first flag"] static FlagA = 0x00000001, static FlagB = 0x00000010, static FlagC = 0x00000100 } )
2014-05-05log: Logger receiveis a LogRecordSean McArthur-0/+6
The logging macros now create a LogRecord, and pass that to the Logger, instead of passing a `level` and `args`. The new signature is: trait Logger { fn log(&mut self, record: &LogRecord); } The LogRecord includes additional values that may be useful to custom loggers, and also allows for further expansion if not values are found useful. DefaultLogger's formatting was taken from Python's default formatting: `LEVEL:from: message` Also included: fmt::Arguments now implement Show, so they can be used to extend format strings. [breaking-change]
2014-05-05std::comm: use Unsafe to avoid U.B. & -> &mut transmutes.Huon Wilson-34/+49