github.com/avfs/avfs@v0.33.1-0.20240303173310-c6ba67c33eb7/curuser.go (about)

     1  package avfs
     2  
     3  // CurUserMgr is the interface that wraps the current user related methods of a file system.
     4  type CurUserMgr interface {
     5  	// SetUser sets the current user.
     6  	// If the user can't be changed an error is returned.
     7  	SetUser(user UserReader) error
     8  
     9  	// SetUserByName sets the current user by name.
    10  	// If the user is not found, the returned error is of type UnknownUserError.
    11  	SetUserByName(name string) error
    12  
    13  	// User returns the current user.
    14  	User() UserReader
    15  }
    16  
    17  // CurUserFn provides current user functions to a file system.
    18  type CurUserFn struct {
    19  	user UserReader
    20  }
    21  
    22  // SetUser sets the current user.
    23  func (vst *CurUserFn) SetUser(user UserReader) error {
    24  	vst.user = user
    25  
    26  	return nil
    27  }
    28  
    29  // User returns the current user.
    30  func (vst *CurUserFn) User() UserReader {
    31  	return vst.user
    32  }