Blob


1 package p9p
3 import "context"
5 // Session provides the central abstraction for a 9p connection. Clients
6 // implement sessions and servers serve sessions. Sessions can be proxied by
7 // serving up a client session.
8 //
9 // The interface is also wired up with full context support to manage timeouts
10 // and resource clean up.
11 //
12 // Session represents the operations covered in section 5 of the plan 9 manual
13 // (http://man.cat-v.org/plan_9/5/). Requests are managed internally, so the
14 // Flush method is handled by the internal implementation. Consider preceeding
15 // these all with context to control request timeout.
16 type Session interface {
17 Auth(ctx context.Context, afid Fid, uname, aname string) (Qid, error)
18 Attach(ctx context.Context, fid, afid Fid, uname, aname string) (Qid, error)
19 Clunk(ctx context.Context, fid Fid) error
20 Remove(ctx context.Context, fid Fid) error
21 Walk(ctx context.Context, fid Fid, newfid Fid, names ...string) ([]Qid, error)
23 // Read follows the semantics of io.ReaderAt.ReadAtt method except it takes
24 // a contxt and Fid.
25 Read(ctx context.Context, fid Fid, p []byte, offset int64) (n int, err error)
27 // Write follows the semantics of io.WriterAt.WriteAt except takes a context and an Fid.
28 //
29 // If n == len(p), no error is returned.
30 // If n < len(p), io.ErrShortWrite will be returned.
31 Write(ctx context.Context, fid Fid, p []byte, offset int64) (n int, err error)
33 Open(ctx context.Context, fid Fid, mode Flag) (Qid, uint32, error)
34 Create(ctx context.Context, parent Fid, name string, perm uint32, mode Flag) (Qid, uint32, error)
35 Stat(ctx context.Context, fid Fid) (Dir, error)
36 WStat(ctx context.Context, fid Fid, dir Dir) error
38 // Version returns the supported version and msize of the session. This
39 // can be affected by negotiating or the level of support provided by the
40 // session implementation.
41 Version() (msize int, version string)
42 }