rust/chg/src/message.rs
author Raphaël Gomès <rgomes@octobus.net>
Fri, 29 Nov 2019 18:33:56 +0100
changeset 43832 1bb4e9b02984
parent 43818 ce088b38f92b
child 44674 8a7beeea655f
permissions -rw-r--r--
rust-matchers: improve `Matcher` trait ergonomics `VisitChildrenSet` has no need to own the set, this will save allocations. The `file_set` return type change is motivated by both ergonomics and... being able to compile code. The `AlwaysMatcher` does not store a `file_set`, which requires it to return an owned `HashSet`, which in turn would change our return type to `Cow<&HgPath>` (lifetimes omitted). This is both un-ergonomic and troublesome for more complex lifetime issues (especially with the upcoming `FileMatcher` in the following patch). Differential Revision: https://phab.mercurial-scm.org/D7525
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     1
// Copyright 2018 Yuya Nishihara <yuya@tcha.org>
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     2
//
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     3
// This software may be used and distributed according to the terms of the
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     4
// GNU General Public License version 2 or any later version.
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     5
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     6
//! Utility for parsing and building command-server messages.
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     7
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     8
use bytes::Bytes;
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
     9
use std::error;
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    10
use std::ffi::{OsStr, OsString};
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    11
use std::io;
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    12
use std::os::unix::ffi::OsStrExt;
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    13
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    14
pub use tokio_hglib::message::*; // re-exports
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    15
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    16
/// Shell command type requested by the server.
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    17
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    18
pub enum CommandType {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    19
    /// Pager should be spawned.
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    20
    Pager,
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    21
    /// Shell command should be executed to send back the result code.
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    22
    System,
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    23
}
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    24
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    25
/// Shell command requested by the server.
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    26
#[derive(Clone, Debug, Eq, PartialEq)]
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    27
pub struct CommandSpec {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    28
    pub command: OsString,
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    29
    pub current_dir: OsString,
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    30
    pub envs: Vec<(OsString, OsString)>,
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    31
}
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    32
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    33
/// Parses "S" channel request into command type and spec.
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    34
pub fn parse_command_spec(data: Bytes) -> io::Result<(CommandType, CommandSpec)> {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    35
    let mut split = data.split(|&c| c == b'\0');
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    36
    let ctype = parse_command_type(split.next().ok_or(new_parse_error("missing type"))?)?;
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    37
    let command = split.next().ok_or(new_parse_error("missing command"))?;
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    38
    let current_dir = split.next().ok_or(new_parse_error("missing current dir"))?;
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    39
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    40
    let mut envs = Vec::new();
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    41
    for l in split {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    42
        let mut s = l.splitn(2, |&c| c == b'=');
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    43
        let k = s.next().unwrap();
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    44
        let v = s.next().ok_or(new_parse_error("malformed env"))?;
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    45
        envs.push((
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    46
            OsStr::from_bytes(k).to_owned(),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    47
            OsStr::from_bytes(v).to_owned(),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    48
        ));
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    49
    }
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    50
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    51
    let spec = CommandSpec {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    52
        command: OsStr::from_bytes(command).to_owned(),
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    53
        current_dir: OsStr::from_bytes(current_dir).to_owned(),
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    54
        envs: envs,
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    55
    };
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    56
    Ok((ctype, spec))
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    57
}
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    58
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    59
fn parse_command_type(value: &[u8]) -> io::Result<CommandType> {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    60
    match value {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    61
        b"pager" => Ok(CommandType::Pager),
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    62
        b"system" => Ok(CommandType::System),
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    63
        _ => Err(new_parse_error(format!(
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    64
            "unknown command type: {}",
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    65
            decode_latin1(value)
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    66
        ))),
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    67
    }
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    68
}
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    69
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    70
fn decode_latin1<S>(s: S) -> String
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    71
where
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    72
    S: AsRef<[u8]>,
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    73
{
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    74
    s.as_ref().iter().map(|&c| c as char).collect()
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    75
}
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    76
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    77
fn new_parse_error<E>(error: E) -> io::Error
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    78
where
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    79
    E: Into<Box<error::Error + Send + Sync>>,
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    80
{
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    81
    io::Error::new(io::ErrorKind::InvalidData, error)
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    82
}
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    83
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    84
#[cfg(test)]
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    85
mod tests {
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    86
    use super::*;
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    87
    use std::os::unix::ffi::OsStringExt;
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    88
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    89
    #[test]
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    90
    fn parse_command_spec_good() {
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    91
        let src = [
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    92
            b"pager".as_ref(),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    93
            b"less -FRX".as_ref(),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    94
            b"/tmp".as_ref(),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    95
            b"LANG=C".as_ref(),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    96
            b"HGPLAIN=".as_ref(),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    97
        ]
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
    98
        .join(&0);
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
    99
        let spec = CommandSpec {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   100
            command: os_string_from(b"less -FRX"),
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   101
            current_dir: os_string_from(b"/tmp"),
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
   102
            envs: vec![
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
   103
                (os_string_from(b"LANG"), os_string_from(b"C")),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
   104
                (os_string_from(b"HGPLAIN"), os_string_from(b"")),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
   105
            ],
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   106
        };
43818
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
   107
        assert_eq!(
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
   108
            parse_command_spec(Bytes::from(src)).unwrap(),
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
   109
            (CommandType::Pager, spec)
ce088b38f92b rust: run rustfmt
Gregory Szorc <gregory.szorc@gmail.com>
parents: 39971
diff changeset
   110
        );
39971
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   111
    }
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   112
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   113
    #[test]
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   114
    fn parse_command_spec_too_short() {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   115
        assert!(parse_command_spec(Bytes::from_static(b"")).is_err());
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   116
        assert!(parse_command_spec(Bytes::from_static(b"pager")).is_err());
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   117
        assert!(parse_command_spec(Bytes::from_static(b"pager\0less")).is_err());
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   118
    }
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   119
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   120
    #[test]
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   121
    fn parse_command_spec_malformed_env() {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   122
        assert!(parse_command_spec(Bytes::from_static(b"pager\0less\0/tmp\0HOME")).is_err());
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   123
    }
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   124
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   125
    #[test]
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   126
    fn parse_command_spec_unknown_type() {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   127
        assert!(parse_command_spec(Bytes::from_static(b"paper\0less")).is_err());
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   128
    }
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   129
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   130
    fn os_string_from(s: &[u8]) -> OsString {
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   131
        OsString::from_vec(s.to_vec())
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   132
    }
b1d8acd82d60 rust-chg: add parser for request messages sent to "S" channel
Yuya Nishihara <yuya@tcha.org>
parents:
diff changeset
   133
}