Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
int
Rust
提交
dbf6abf6
R
Rust
项目概览
int
/
Rust
大约 1 年 前同步成功
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
Rust
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
dbf6abf6
编写于
8月 30, 2012
作者:
B
Brian Anderson
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
std: Camel case net modules
上级
afc1ccd2
变更
4
展开全部
隐藏空白更改
内联
并排
Showing
4 changed file
with
256 addition
and
252 deletion
+256
-252
src/libstd/net_ip.rs
src/libstd/net_ip.rs
+34
-34
src/libstd/net_tcp.rs
src/libstd/net_tcp.rs
+146
-146
src/libstd/net_url.rs
src/libstd/net_url.rs
+72
-72
src/libstd/std.rc
src/libstd/std.rc
+4
-0
未找到文件。
src/libstd/net_ip.rs
浏览文件 @
dbf6abf6
...
...
@@ -21,21 +21,21 @@
import
ll
=
uv
::
ll
;
import
comm
=
core
::
comm
;
export
ip_a
ddr
,
parse_addr_err
;
export
IpA
ddr
,
parse_addr_err
;
export
format_addr
;
export
v4
,
v6
;
export
get_addr
;
export
ipv4
,
i
pv6
;
export
Ipv4
,
I
pv6
;
/// An IP address
enum
ip_a
ddr
{
enum
IpA
ddr
{
/// An IPv4 address
i
pv4
(
sockaddr_in
),
i
pv6
(
sockaddr_in6
)
I
pv4
(
sockaddr_in
),
I
pv6
(
sockaddr_in6
)
}
/// Human-friendly feedback on why a parse_addr attempt failed
type
parse_addr_e
rr
=
{
type
ParseAddrE
rr
=
{
err_msg
:
~
str
};
...
...
@@ -46,16 +46,16 @@ enum ip_addr {
*
* * ip - a `std::net::ip::ip_addr`
*/
fn
format_addr
(
ip
:
ip_a
ddr
)
->
~
str
{
fn
format_addr
(
ip
:
IpA
ddr
)
->
~
str
{
match
ip
{
i
pv4
(
addr
)
=>
unsafe
{
I
pv4
(
addr
)
=>
unsafe
{
let
result
=
uv_ip4_name
(
&
addr
);
if
result
==
~
""
{
fail
~
"failed to convert inner sockaddr_in address to str"
}
result
},
i
pv6
(
addr
)
=>
unsafe
{
I
pv6
(
addr
)
=>
unsafe
{
let
result
=
uv_ip6_name
(
&
addr
);
if
result
==
~
""
{
fail
~
"failed to convert inner sockaddr_in address to str"
...
...
@@ -66,8 +66,8 @@ fn format_addr(ip: ip_addr) -> ~str {
}
/// Represents errors returned from `net::ip::get_addr()`
enum
ip_get_addr_e
rr
{
get_addr_unknown_e
rror
enum
IpGetAddrE
rr
{
GetAddrUnknownE
rror
}
/**
...
...
@@ -85,13 +85,13 @@ enum ip_get_addr_err {
* object in the case of failure
*/
fn
get_addr
(
++
node
:
~
str
,
iotask
:
iotask
)
->
result
::
Result
<~
[
ip_addr
],
ip_get_addr_e
rr
>
{
->
result
::
Result
<~
[
IpAddr
],
IpGetAddrE
rr
>
{
do
core
::
comm
::
listen
|
output_ch
|
{
do
str
::
as_buf
(
node
)
|
node_ptr
,
len
|
unsafe
{
log
(
debug
,
fmt!
(
"slice len %?"
,
len
));
let
handle
=
create_uv_getaddrinfo_t
();
let
handle_ptr
=
ptr
::
addr_of
(
handle
);
let
handle_data
:
get_addr_d
ata
=
{
let
handle_data
:
GetAddrD
ata
=
{
output_ch
:
output_ch
};
let
handle_data_ptr
=
ptr
::
addr_of
(
handle_data
);
...
...
@@ -108,7 +108,7 @@ fn get_addr(++node: ~str, iotask: iotask)
set_data_for_req
(
handle_ptr
,
handle_data_ptr
);
}
_
=>
{
output_ch
.send
(
result
::
Err
(
get_addr_unknown_e
rror
));
output_ch
.send
(
result
::
Err
(
GetAddrUnknownE
rror
));
}
}
};
...
...
@@ -133,7 +133,7 @@ mod v4 {
*
* * an `ip_addr` of the `ipv4` variant
*/
fn
parse_addr
(
ip
:
~
str
)
->
ip_a
ddr
{
fn
parse_addr
(
ip
:
~
str
)
->
IpA
ddr
{
match
try_parse_addr
(
ip
)
{
result
::
Ok
(
addr
)
=>
copy
(
addr
),
result
::
Err
(
err_data
)
=>
fail
err_data
.err_msg
...
...
@@ -141,19 +141,19 @@ fn parse_addr(ip: ~str) -> ip_addr {
}
// the simple, old style numberic representation of
// ipv4
type
ipv4_r
ep
=
{
a
:
u8
,
b
:
u8
,
c
:
u8
,
d
:
u8
};
type
Ipv4R
ep
=
{
a
:
u8
,
b
:
u8
,
c
:
u8
,
d
:
u8
};
trait
as_unsafe_u
32
{
trait
AsUnsafeU
32
{
unsafe
fn
as_u32
()
->
u32
;
}
impl
ipv4_rep
:
as_unsafe_u
32
{
impl
Ipv4Rep
:
AsUnsafeU
32
{
// this is pretty dastardly, i know
unsafe
fn
as_u32
()
->
u32
{
*
((
ptr
::
addr_of
(
self
))
as
*
u32
)
}
}
fn
parse_to_ipv4_rep
(
ip
:
~
str
)
->
result
::
Result
<
ipv4_r
ep
,
~
str
>
{
fn
parse_to_ipv4_rep
(
ip
:
~
str
)
->
result
::
Result
<
Ipv4R
ep
,
~
str
>
{
let
parts
=
vec
::
map
(
str
::
split_char
(
ip
,
'.'
),
|
s
|
{
match
uint
::
from_str
(
s
)
{
Some
(
n
)
if
n
<=
255u
=>
n
,
...
...
@@ -171,7 +171,7 @@ fn parse_to_ipv4_rep(ip: ~str) -> result::Result<ipv4_rep, ~str> {
c
:
parts
[
2
]
as
u8
,
d
:
parts
[
3
]
as
u8
})
}
}
fn
try_parse_addr
(
ip
:
~
str
)
->
result
::
Result
<
ip_addr
,
parse_addr_e
rr
>
{
fn
try_parse_addr
(
ip
:
~
str
)
->
result
::
Result
<
IpAddr
,
ParseAddrE
rr
>
{
unsafe
{
let
INADDR_NONE
=
ll
::
get_INADDR_NONE
();
let
ip_rep_result
=
parse_to_ipv4_rep
(
ip
);
...
...
@@ -198,7 +198,7 @@ fn try_parse_addr(ip: ~str) -> result::Result<ip_addr,parse_addr_err> {
{
err_msg
:
~
"uv_ip4_name produced invalid result."
})
}
else
{
result
::
Ok
(
i
pv4
(
copy
(
new_addr
)))
result
::
Ok
(
I
pv4
(
copy
(
new_addr
)))
}
}
}
...
...
@@ -219,13 +219,13 @@ mod v6 {
*
* * an `ip_addr` of the `ipv6` variant
*/
fn
parse_addr
(
ip
:
~
str
)
->
ip_a
ddr
{
fn
parse_addr
(
ip
:
~
str
)
->
IpA
ddr
{
match
try_parse_addr
(
ip
)
{
result
::
Ok
(
addr
)
=>
copy
(
addr
),
result
::
Err
(
err_data
)
=>
fail
err_data
.err_msg
}
}
fn
try_parse_addr
(
ip
:
~
str
)
->
result
::
Result
<
ip_addr
,
parse_addr_e
rr
>
{
fn
try_parse_addr
(
ip
:
~
str
)
->
result
::
Result
<
IpAddr
,
ParseAddrE
rr
>
{
unsafe
{
// need to figure out how to establish a parse failure..
let
new_addr
=
uv_ip6_addr
(
ip
,
22
);
...
...
@@ -239,21 +239,21 @@ fn try_parse_addr(ip: ~str) -> result::Result<ip_addr,parse_addr_err> {
ip
)})
}
else
{
result
::
Ok
(
i
pv6
(
new_addr
))
result
::
Ok
(
I
pv6
(
new_addr
))
}
}
}
}
type
get_addr_d
ata
=
{
output_ch
:
comm
::
Chan
<
result
::
Result
<~
[
ip_addr
],
ip_get_addr_e
rr
>>
type
GetAddrD
ata
=
{
output_ch
:
comm
::
Chan
<
result
::
Result
<~
[
IpAddr
],
IpGetAddrE
rr
>>
};
extern
fn
get_addr_cb
(
handle
:
*
uv_getaddrinfo_t
,
status
:
libc
::
c_int
,
res
:
*
addrinfo
)
unsafe
{
log
(
debug
,
~
"in get_addr_cb"
);
let
handle_data
=
get_data_for_req
(
handle
)
as
*
get_addr_d
ata
;
*
GetAddrD
ata
;
if
status
==
0i32
{
if
res
!=
(
ptr
::
null
::
<
addrinfo
>
())
{
let
mut
out_vec
=
~
[];
...
...
@@ -261,18 +261,18 @@ fn try_parse_addr(ip: ~str) -> result::Result<ip_addr,parse_addr_err> {
let
mut
curr_addr
=
res
;
loop
{
let
new_ip_addr
=
if
ll
::
is_ipv4_addrinfo
(
curr_addr
)
{
i
pv4
(
copy
((
I
pv4
(
copy
((
*
ll
::
addrinfo_as_sockaddr_in
(
curr_addr
))))
}
else
if
ll
::
is_ipv6_addrinfo
(
curr_addr
)
{
i
pv6
(
copy
((
I
pv6
(
copy
((
*
ll
::
addrinfo_as_sockaddr_in6
(
curr_addr
))))
}
else
{
log
(
debug
,
~
"curr_addr is not of family AF_INET or "
+
~
"AF_INET6. Error."
);
(
*
handle_data
)
.output_ch
.send
(
result
::
Err
(
get_addr_unknown_e
rror
));
result
::
Err
(
GetAddrUnknownE
rror
));
break
;
};
out_vec
+=
~
[
new_ip_addr
];
...
...
@@ -294,13 +294,13 @@ fn try_parse_addr(ip: ~str) -> result::Result<ip_addr,parse_addr_err> {
else
{
log
(
debug
,
~
"addrinfo pointer is NULL"
);
(
*
handle_data
)
.output_ch
.send
(
result
::
Err
(
get_addr_unknown_e
rror
));
result
::
Err
(
GetAddrUnknownE
rror
));
}
}
else
{
log
(
debug
,
~
"status != 0 error in get_addr_cb"
);
(
*
handle_data
)
.output_ch
.send
(
result
::
Err
(
get_addr_unknown_e
rror
));
result
::
Err
(
GetAddrUnknownE
rror
));
}
if
res
!=
(
ptr
::
null
::
<
addrinfo
>
())
{
uv_freeaddrinfo
(
res
);
...
...
@@ -365,8 +365,8 @@ fn test_ip_get_addr() {
localhost_name
,
vec
::
len
(
results
)));
for
vec
::
each
(
results
)
|
r
|
{
let
ipv_prefix
=
match
r
{
i
pv4
(
_
)
=>
~
"IPv4"
,
i
pv6
(
_
)
=>
~
"IPv6"
I
pv4
(
_
)
=>
~
"IPv4"
,
I
pv6
(
_
)
=>
~
"IPv6"
};
log
(
debug
,
fmt!
(
"test_get_addr: result %s: '%s'"
,
ipv_prefix
,
format_addr
(
r
)));
...
...
src/libstd/net_tcp.rs
浏览文件 @
dbf6abf6
此差异已折叠。
点击以展开。
src/libstd/net_url.rs
浏览文件 @
dbf6abf6
...
...
@@ -6,7 +6,7 @@
import
io
::{
Reader
,
ReaderUtil
};
import
dvec
::
DVec
;
export
u
rl
,
userinfo
,
query
;
export
U
rl
,
userinfo
,
query
;
export
from_str
,
to_str
;
export
get_scheme
;
...
...
@@ -14,31 +14,31 @@
export
encode_component
,
decode_component
;
export
encode_form_urlencoded
,
decode_form_urlencoded
;
type
u
rl
=
{
type
U
rl
=
{
scheme
:
~
str
,
user
:
Option
<
useri
nfo
>
,
user
:
Option
<
UserI
nfo
>
,
host
:
~
str
,
port
:
Option
<~
str
>
,
path
:
~
str
,
query
:
q
uery
,
query
:
Q
uery
,
fragment
:
Option
<~
str
>
};
type
useri
nfo
=
{
type
UserI
nfo
=
{
user
:
~
str
,
pass
:
Option
<~
str
>
};
type
q
uery
=
~
[(
~
str
,
~
str
)];
type
Q
uery
=
~
[(
~
str
,
~
str
)];
fn
url
(
-
scheme
:
~
str
,
-
user
:
Option
<
useri
nfo
>
,
-
host
:
~
str
,
-
port
:
Option
<~
str
>
,
-
path
:
~
str
,
-
query
:
q
uery
,
-
fragment
:
Option
<~
str
>
)
->
u
rl
{
fn
url
(
-
scheme
:
~
str
,
-
user
:
Option
<
UserI
nfo
>
,
-
host
:
~
str
,
-
port
:
Option
<~
str
>
,
-
path
:
~
str
,
-
query
:
Q
uery
,
-
fragment
:
Option
<~
str
>
)
->
U
rl
{
{
scheme
:
scheme
,
user
:
user
,
host
:
host
,
port
:
port
,
path
:
path
,
query
:
query
,
fragment
:
fragment
}
}
fn
userinfo
(
-
user
:
~
str
,
-
pass
:
Option
<~
str
>
)
->
useri
nfo
{
fn
userinfo
(
-
user
:
~
str
,
-
pass
:
Option
<~
str
>
)
->
UserI
nfo
{
{
user
:
user
,
pass
:
pass
}
}
...
...
@@ -290,7 +290,7 @@ fn split_char_first(s: ~str, c: char) -> (~str, ~str) {
}
}
fn
userinfo_from_str
(
uinfo
:
~
str
)
->
useri
nfo
{
fn
userinfo_from_str
(
uinfo
:
~
str
)
->
UserI
nfo
{
let
(
user
,
p
)
=
split_char_first
(
uinfo
,
':'
);
let
pass
=
if
str
::
len
(
p
)
==
0
{
option
::
None
...
...
@@ -300,7 +300,7 @@ fn userinfo_from_str(uinfo: ~str) -> userinfo {
return
userinfo
(
user
,
pass
);
}
fn
userinfo_to_str
(
-
userinfo
:
useri
nfo
)
->
~
str
{
fn
userinfo_to_str
(
-
userinfo
:
UserI
nfo
)
->
~
str
{
if
option
::
is_some
(
userinfo
.pass
)
{
return
str
::
concat
(
~
[
copy
userinfo
.user
,
~
":"
,
option
::
unwrap
(
copy
userinfo
.pass
),
...
...
@@ -310,14 +310,14 @@ fn userinfo_to_str(-userinfo: userinfo) -> ~str {
}
}
impl
useri
nfo
:
Eq
{
pure
fn
eq
(
&&
other
:
useri
nfo
)
->
bool
{
impl
UserI
nfo
:
Eq
{
pure
fn
eq
(
&&
other
:
UserI
nfo
)
->
bool
{
self
.user
==
other
.user
&&
self
.pass
==
other
.pass
}
}
fn
query_from_str
(
rawquery
:
~
str
)
->
q
uery
{
let
mut
query
:
q
uery
=
~
[];
fn
query_from_str
(
rawquery
:
~
str
)
->
Q
uery
{
let
mut
query
:
Q
uery
=
~
[];
if
str
::
len
(
rawquery
)
!=
0
{
for
str
::
split_char
(
rawquery
,
'&'
)
.each
|
p
|
{
let
(
k
,
v
)
=
split_char_first
(
p
,
'='
);
...
...
@@ -327,7 +327,7 @@ fn query_from_str(rawquery: ~str) -> query {
return
query
;
}
fn
query_to_str
(
query
:
q
uery
)
->
~
str
{
fn
query_to_str
(
query
:
Q
uery
)
->
~
str
{
let
mut
strvec
=
~
[];
for
query
.each
|
kv
|
{
let
(
k
,
v
)
=
copy
kv
;
...
...
@@ -363,47 +363,47 @@ fn get_scheme(rawurl: ~str) -> result::Result<(~str, ~str), @~str> {
return
result
::
Err
(
@~
"url: Scheme must be terminated with a colon."
);
}
enum
i
nput
{
d
igit
,
// all digits
h
ex
,
// digits and letters a-f
u
nreserved
// all other legal characters
enum
I
nput
{
D
igit
,
// all digits
H
ex
,
// digits and letters a-f
U
nreserved
// all other legal characters
}
impl
i
nput
:
Eq
{
pure
fn
eq
(
&&
other
:
i
nput
)
->
bool
{
impl
I
nput
:
Eq
{
pure
fn
eq
(
&&
other
:
I
nput
)
->
bool
{
match
(
self
,
other
)
{
(
digit
,
d
igit
)
=>
true
,
(
hex
,
h
ex
)
=>
true
,
(
unreserved
,
u
nreserved
)
=>
true
,
(
d
igit
,
_
)
=>
false
,
(
h
ex
,
_
)
=>
false
,
(
u
nreserved
,
_
)
=>
false
(
Digit
,
D
igit
)
=>
true
,
(
Hex
,
H
ex
)
=>
true
,
(
Unreserved
,
U
nreserved
)
=>
true
,
(
D
igit
,
_
)
=>
false
,
(
H
ex
,
_
)
=>
false
,
(
U
nreserved
,
_
)
=>
false
}
}
}
// returns userinfo, host, port, and unparsed part, or an error
fn
get_authority
(
rawurl
:
~
str
)
->
result
::
Result
<
(
Option
<
useri
nfo
>
,
~
str
,
Option
<~
str
>
,
~
str
),
@~
str
>
{
result
::
Result
<
(
Option
<
UserI
nfo
>
,
~
str
,
Option
<~
str
>
,
~
str
),
@~
str
>
{
if
!
str
::
starts_with
(
rawurl
,
~
"//"
)
{
// there is no authority.
return
result
::
Ok
((
option
::
None
,
~
""
,
option
::
None
,
copy
rawurl
));
}
enum
s
tate
{
s
tart
,
// starting state
pass_host_p
ort
,
// could be in user or port
ip6_p
ort
,
// either in ipv6 host or port
ip6_h
ost
,
// are in an ipv6 host
in_h
ost
,
// are in a host - may be ipv6, but don't know yet
in_p
ort
// are in port
enum
S
tate
{
S
tart
,
// starting state
PassHostP
ort
,
// could be in user or port
Ip6P
ort
,
// either in ipv6 host or port
Ip6H
ost
,
// are in an ipv6 host
InH
ost
,
// are in a host - may be ipv6, but don't know yet
InP
ort
// are in port
}
let
len
=
str
::
len
(
rawurl
);
let
mut
st
:
state
=
s
tart
;
let
mut
in
:
input
=
d
igit
;
// most restricted, start here.
let
mut
st
:
State
=
S
tart
;
let
mut
in
:
Input
=
D
igit
;
// most restricted, start here.
let
mut
userinfo
:
Option
<
useri
nfo
>
=
option
::
None
;
let
mut
userinfo
:
Option
<
UserI
nfo
>
=
option
::
None
;
let
mut
host
:
~
str
=
~
""
;
let
mut
port
:
option
::
Option
<~
str
>
=
option
::
None
;
...
...
@@ -417,13 +417,13 @@ enum state {
match
c
{
'0'
to
'9'
=>
(),
'A'
to
'F'
|
'a'
to
'f'
=>
{
if
in
==
d
igit
{
in
=
h
ex
;
if
in
==
D
igit
{
in
=
H
ex
;
}
}
'G'
to
'Z'
|
'g'
to
'z'
|
'-'
|
'.'
|
'_'
|
'~'
|
'%'
|
'&'
|
'\''
|
'('
|
')'
|
'+'
|
'!'
|
'*'
|
','
|
';'
|
'='
=>
{
in
=
u
nreserved
;
in
=
U
nreserved
;
}
':'
|
'@'
|
'?'
|
'#'
|
'/'
=>
{
// separators, don't change anything
...
...
@@ -438,62 +438,62 @@ enum state {
':'
=>
{
colon_count
+=
1
;
match
st
{
s
tart
=>
{
S
tart
=>
{
pos
=
i
;
st
=
pass_host_p
ort
;
st
=
PassHostP
ort
;
}
pass_host_p
ort
=>
{
PassHostP
ort
=>
{
// multiple colons means ipv6 address.
if
in
==
u
nreserved
{
if
in
==
U
nreserved
{
return
result
::
Err
(
@~
"Illegal characters in IPv6 address."
);
}
st
=
ip6_h
ost
;
st
=
Ip6H
ost
;
}
in_h
ost
=>
{
InH
ost
=>
{
pos
=
i
;
// can't be sure whether this is an ipv6 address or a port
if
in
==
u
nreserved
{
if
in
==
U
nreserved
{
return
result
::
Err
(
@~
"Illegal characters in authority."
);
}
st
=
ip6_p
ort
;
st
=
Ip6P
ort
;
}
ip6_p
ort
=>
{
if
in
==
u
nreserved
{
Ip6P
ort
=>
{
if
in
==
U
nreserved
{
return
result
::
Err
(
@~
"Illegal characters in authority."
);
}
st
=
ip6_h
ost
;
st
=
Ip6H
ost
;
}
ip6_h
ost
=>
{
Ip6H
ost
=>
{
if
colon_count
>
7
{
host
=
str
::
slice
(
rawurl
,
begin
,
i
);
pos
=
i
;
st
=
in_p
ort
;
st
=
InP
ort
;
}
}
_
=>
{
return
result
::
Err
(
@~
"Invalid ':' in authority."
);
}
}
in
=
d
igit
;
// reset input class
in
=
D
igit
;
// reset input class
}
'@'
=>
{
in
=
d
igit
;
// reset input class
in
=
D
igit
;
// reset input class
colon_count
=
0
;
// reset count
match
st
{
s
tart
=>
{
S
tart
=>
{
let
user
=
str
::
slice
(
rawurl
,
begin
,
i
);
userinfo
=
option
::
Some
({
user
:
user
,
pass
:
option
::
None
});
st
=
in_h
ost
;
st
=
InH
ost
;
}
pass_host_p
ort
=>
{
PassHostP
ort
=>
{
let
user
=
str
::
slice
(
rawurl
,
begin
,
pos
);
let
pass
=
str
::
slice
(
rawurl
,
pos
+
1
,
i
);
userinfo
=
option
::
Some
({
user
:
user
,
pass
:
option
::
Some
(
pass
)});
st
=
in_h
ost
;
st
=
InH
ost
;
}
_
=>
{
return
result
::
Err
(
@~
"Invalid '@' in authority."
);
...
...
@@ -520,25 +520,25 @@ enum state {
// finish up
match
st
{
s
tart
=>
{
S
tart
=>
{
if
host_is_end_plus_one
()
{
host
=
str
::
slice
(
rawurl
,
begin
,
end
+
1
);
}
else
{
host
=
str
::
slice
(
rawurl
,
begin
,
end
);
}
}
pass_host_port
|
ip6_p
ort
=>
{
if
in
!=
d
igit
{
PassHostPort
|
Ip6P
ort
=>
{
if
in
!=
D
igit
{
return
result
::
Err
(
@~
"Non-digit characters in port."
);
}
host
=
str
::
slice
(
rawurl
,
begin
,
pos
);
port
=
option
::
Some
(
str
::
slice
(
rawurl
,
pos
+
1
,
end
));
}
ip6_host
|
in_h
ost
=>
{
Ip6Host
|
InH
ost
=>
{
host
=
str
::
slice
(
rawurl
,
begin
,
end
);
}
in_p
ort
=>
{
if
in
!=
d
igit
{
InP
ort
=>
{
if
in
!=
D
igit
{
return
result
::
Err
(
@~
"Non-digit characters in port."
);
}
port
=
option
::
Some
(
str
::
slice
(
rawurl
,
pos
+
1
,
end
));
...
...
@@ -584,7 +584,7 @@ fn get_path(rawurl: ~str, authority : bool) ->
// returns the parsed query and the fragment, if present
fn
get_query_fragment
(
rawurl
:
~
str
)
->
result
::
Result
<
(
q
uery
,
Option
<~
str
>
),
@~
str
>
{
result
::
Result
<
(
Q
uery
,
Option
<~
str
>
),
@~
str
>
{
if
!
str
::
starts_with
(
rawurl
,
~
"?"
)
{
if
str
::
starts_with
(
rawurl
,
~
"#"
)
{
let
f
=
decode_component
(
str
::
slice
(
rawurl
,
...
...
@@ -615,7 +615,7 @@ fn get_query_fragment(rawurl: ~str) ->
*
*/
fn
from_str
(
rawurl
:
~
str
)
->
result
::
Result
<
u
rl
,
~
str
>
{
fn
from_str
(
rawurl
:
~
str
)
->
result
::
Result
<
U
rl
,
~
str
>
{
// scheme
let
mut
schm
=
get_scheme
(
rawurl
);
if
result
::
is_err
(
schm
)
{
...
...
@@ -664,7 +664,7 @@ fn from_str(rawurl: ~str) -> result::Result<url, ~str> {
* result in just "http://somehost.com".
*
*/
fn
to_str
(
url
:
u
rl
)
->
~
str
{
fn
to_str
(
url
:
U
rl
)
->
~
str
{
let
user
=
if
option
::
is_some
(
url
.user
)
{
userinfo_to_str
(
option
::
unwrap
(
copy
url
.user
))
}
else
{
...
...
@@ -695,7 +695,7 @@ fn to_str(url: url) -> ~str {
fragment
]);
}
impl
u
rl
:
to_str
::
ToStr
{
impl
U
rl
:
to_str
::
ToStr
{
fn
to_str
()
->
~
str
{
to_str
(
self
)
}
...
...
src/libstd/std.rc
浏览文件 @
dbf6abf6
...
...
@@ -30,9 +30,13 @@ export cell;
// General io and system-services modules
#[warn(non_camel_case_types)]
mod net;
#[warn(non_camel_case_types)]
mod net_ip;
#[warn(non_camel_case_types)]
mod net_tcp;
#[warn(non_camel_case_types)]
mod net_url;
// libuv modules
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录