package com.jscape.inet.sftp.protocol.v4.marshaling;

import com.jscape.inet.sftp.protocol.messages.Message;
import com.jscape.inet.sftp.protocol.v4.messages.SshFxpInit;
import com.jscape.inet.ssh.protocol.v2.marshaling.primitive.Uint32Codec;
import com.jscape.util.io.DataCodec;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;

/**
 * @author Alex Usun
 */
public class SshFxpInitCodec
        implements DataCodec<Message> {

    @Override
    public Message read(InputStream in)
            throws IOException {
        int version = Uint32Codec.readValue(in);
        return new SshFxpInit(version);
    }

    @Override
    public void write(Message value, OutputStream out)
            throws IOException {
        SshFxpInit message = (SshFxpInit) value;
        Uint32Codec.writeValue(message.version, out);
    }
}
