8 Tversion FcallType = iota + 100
39 func (fct FcallType) String() string {
109 func newFcall(msg Message) *Fcall {
113 case Tversion, Rversion:
124 func newErrorFcall(tag Tag, err error) *Fcall {
127 switch v := err.(type) {
133 msg = MessageRerror{Ename: v.Error()}
143 func (fc *Fcall) String() string {
144 return fmt.Sprintf("%v(%v) %v", fc.Type, fc.Tag, string9p(fc.Message))
147 type Message interface {
148 // Type indicates the Fcall type of the message. This must match
153 // newMessage returns a new instance of the message based on the Fcall type.
154 func newMessage(typ FcallType) (Message, error) {
155 // NOTE(stevvooe): This is a nasty bit of code but makes the transport
156 // fairly simple to implement.
159 return &MessageTversion{}, nil
161 return &MessageRversion{}, nil
163 return &MessageTauth{}, nil
165 return &MessageRauth{}, nil
167 return &MessageTattach{}, nil
169 return &MessageRattach{}, nil
171 return &MessageRerror{}, nil
173 return &MessageTflush{}, nil
175 return &MessageRflush{}, nil // No message body for this response.
177 return &MessageTwalk{}, nil
179 return &MessageRwalk{}, nil
181 return &MessageTopen{}, nil
183 return &MessageRopen{}, nil
185 return &MessageTcreate{}, nil
187 return &MessageRcreate{}, nil
189 return &MessageTread{}, nil
191 return &MessageRread{}, nil
193 return &MessageTwrite{}, nil
195 return &MessageRwrite{}, nil
197 return &MessageTclunk{}, nil
199 return &MessageRclunk{}, nil // no response body
207 return &MessageRstat{}, nil
214 return nil, fmt.Errorf("unknown message type")
217 // MessageVersion encodes the message body for Tversion and Rversion RPC
218 // calls. The body is identical in both directions.
219 type MessageTversion struct {
224 type MessageRversion struct {
229 type MessageTauth struct {
235 type MessageRauth struct {
239 type MessageRerror struct {
243 func (e MessageRerror) Error() string {
244 return fmt.Sprintf("9p: %v", e.Ename)
247 type MessageTflush struct {
251 type MessageRflush struct{}
253 type MessageTattach struct {
260 type MessageRattach struct {
264 type MessageTwalk struct {
270 type MessageRwalk struct {
274 type MessageTopen struct {
279 type MessageRopen struct {
284 type MessageTcreate struct {
291 type MessageRcreate struct {
296 type MessageTread struct {
302 type MessageRread struct {
306 type MessageTwrite struct {
312 type MessageRwrite struct {
316 type MessageTclunk struct {
320 type MessageRclunk struct{}
322 type MessageTremove struct {
326 type MessageRremove struct{}
328 type MessageTstat struct {
332 type MessageRstat struct {
336 type MessageTwstat struct {
341 func (MessageTversion) Type() FcallType { return Tversion }
342 func (MessageRversion) Type() FcallType { return Rversion }
343 func (MessageTauth) Type() FcallType { return Tauth }
344 func (MessageRauth) Type() FcallType { return Rauth }
345 func (MessageTflush) Type() FcallType { return Tflush }
346 func (MessageRflush) Type() FcallType { return Rflush }
347 func (MessageRerror) Type() FcallType { return Rerror }
348 func (MessageTattach) Type() FcallType { return Tattach }
349 func (MessageRattach) Type() FcallType { return Rattach }
350 func (MessageTwalk) Type() FcallType { return Twalk }
351 func (MessageRwalk) Type() FcallType { return Rwalk }
352 func (MessageTopen) Type() FcallType { return Topen }
353 func (MessageRopen) Type() FcallType { return Ropen }
354 func (MessageTcreate) Type() FcallType { return Tcreate }
355 func (MessageRcreate) Type() FcallType { return Rcreate }
356 func (MessageTread) Type() FcallType { return Tread }
357 func (MessageRread) Type() FcallType { return Rread }
358 func (MessageTwrite) Type() FcallType { return Twrite }
359 func (MessageRwrite) Type() FcallType { return Rwrite }
360 func (MessageTclunk) Type() FcallType { return Tclunk }
361 func (MessageRclunk) Type() FcallType { return Rclunk }
362 func (MessageTremove) Type() FcallType { return Tremove }
363 func (MessageRremove) Type() FcallType { return Rremove }
364 func (MessageTstat) Type() FcallType { return Tstat }
365 func (MessageRstat) Type() FcallType { return Rstat }
366 func (MessageTwstat) Type() FcallType { return Twstat }