IMPORTANT: To view this page as Markdown, append `.md` to the URL (e.g. /docs/manual/basics.md). For the complete Mojo documentation index, see llms.txt.
Skip to main content
Version: Nightly
For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).

BorrowedFileDescriptor

struct BorrowedFileDescriptor[origin: ImmOrigin]

Copyable, non-owning view of a FileDescriptor.

The view carries the owner's origin, so it cannot outlive the owner, and it never closes the descriptor. -1 is the niche, so Optional[BorrowedFileDescriptor] is the size of a descriptor.

Examples:

from std.io import BorrowedFileDescriptor, FileDescriptor

def share(var fd: FileDescriptor) raises:
var first = BorrowedFileDescriptor(fd)
var second = first
fd^.close()

Parameters​

  • ​origin (ImmOrigin): The origin of the FileDescriptor this view refers to.

Implemented traits​

AnyType, Copyable, Deinitable, ImplicitlyCopyable, Movable, RegisterPassable, TrivialRegisterPassable, UnsafeNicheable, _FieldNicheable

Methods​

__init__​

@implicit def __init__(ref[origin] fd: FileDescriptor) -> Self

Constructs a view of a FileDescriptor.

Args: