Skip to main content

Mojo struct

FileDescriptor

@register_passable(trivial)

File descriptor of a file.

Fields

  • value (Int): The underlying value of the file descriptor.

Implemented traits

AnyType, Copyable, Movable, MovableWriter, Writer

Methods

__init__

__init__(out self, value: Int = 1)

Constructs the file descriptor from an integer.

Args:

  • value (Int): The file identifier (Default 1 = stdout).

__init__(out self, f: FileHandle)

Constructs the file descriptor from a file handle.

Args:

  • f (FileHandle): The file handle.

write_bytes

write_bytes(inout self, bytes: Span[SIMD[uint8, 1], origin])

Write a span of bytes to the file.

Args:

  • bytes (Span[SIMD[uint8, 1], origin]): The byte span to write to this file.

write

write[*Ts: Writable](inout self, *args: *Ts)

Write a sequence of Writable arguments to the provided Writer.

Parameters:

  • *Ts (Writable): Types of the provided argument sequence.

Args:

  • *args (*Ts): Sequence of arguments to write to this Writer.